CC-4090: Make code style PSR compliant - part 4

-forms directory
This commit is contained in:
Martin Konecny 2012-08-28 23:04:55 -04:00
parent 481616a0d6
commit b2327472e8
29 changed files with 505 additions and 519 deletions

View file

@ -9,7 +9,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
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->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();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
public function checkReliantFields($formData) {
public function checkReliantFields($formData)
{
$noError = true;
for($i=1; $i<=10; $i++) {
for ($i=1; $i<=10; $i++) {
$valid = true;
$day = $formData['add_show_rebroadcast_date_absolute_'.$i];
$time = $formData['add_show_rebroadcast_time_absolute_'.$i];
if(trim($day) == "" && trim($time) == "") {
if (trim($day) == "" && trim($time) == "") {
continue;
}
if (trim($day) == ""){
if (trim($day) == "") {
$this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array("Day must be specified"));
$valid = false;
}
if (trim($time) == ""){
if (trim($time) == "") {
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Time must be specified"));
$valid = false;
}
if($valid === false) {
if ($valid === false) {
$noError = false;
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 = 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"));
$valid = false;
$noError = false;
@ -94,4 +92,3 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
return $noError;
}
}

View file

@ -44,7 +44,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
$this->addElement($custom_password);
$connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
if(trim($connection_url) == ""){
if (trim($connection_url) == "") {
$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);
if($data['cb_custom_auth'] == 1){
if(trim($data['custom_username']) == ''){
if ($data['cb_custom_auth'] == 1) {
if (trim($data['custom_username']) == '') {
$element = $this->getElement("custom_username");
$element->addError("Username field cannot be empty.");
$isValid = false;
}
if(trim($data['custom_password']) == ''){
if (trim($data['custom_password']) == '') {
$element = $this->getElement("custom_password");
$element->addError("Password field cannot be empty.");
$isValid = false;
}
}
return $isValid;
}
}

View file

@ -18,16 +18,14 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm
));
}
public function disable(){
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
}

View file

@ -11,11 +11,11 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
$relativeDates = array();
$relativeDates[""] = "";
for($i=0; $i<=30; $i++) {
for ($i=0; $i<=30; $i++) {
$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->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();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
public function checkReliantFields($formData) {
public function checkReliantFields($formData)
{
$noError = true;
for($i=1; $i<=10; $i++) {
for ($i=1; $i<=10; $i++) {
$valid = true;
$days = $formData['add_show_rebroadcast_date_'.$i];
$time = $formData['add_show_rebroadcast_time_'.$i];
if(trim($days) == "" && trim($time) == "") {
if (trim($days) == "" && trim($time) == "") {
continue;
}
if (trim($days) == ""){
if (trim($days) == "") {
$this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array("Day must be specified"));
$valid = false;
}
if (trim($time) == ""){
if (trim($time) == "") {
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Time must be specified"));
$valid = false;
}
if($valid === false) {
if ($valid === false) {
$noError = false;
continue;
}
@ -93,7 +91,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
$rebroad_start = new DateTime($rebroad_start);
$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"));
$valid = false;
$noError = false;
@ -103,4 +101,3 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
return $noError;
}
}

View file

@ -56,28 +56,28 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
));
}
public function disable(){
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
public function checkReliantFields($formData) {
if (!$formData['add_show_no_end']){
public function checkReliantFields($formData)
{
if (!$formData['add_show_no_end']) {
$start_timestamp = $formData['add_show_start_date'];
$end_timestamp = $formData['add_show_end_date'];
$start_epoch = strtotime($start_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'));
return false;
}
}
@ -86,4 +86,3 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
}
}

View file

@ -24,7 +24,6 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
array('stringLength', false, array(6, 6))
));
// Add show color input
$this->addElement('text', 'add_show_color', array(
'label' => 'Text Colour:',
@ -45,16 +44,14 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
));
}
public function disable(){
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
}

View file

@ -66,15 +66,13 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
}
public function disable(){
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
}

View file

@ -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;
$hours;
@ -96,14 +97,14 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$nowDateTime = new DateTime();
$showStartDateTime = new DateTime($start_time);
$showEndDateTime = new DateTime($end_time);
if ($validateStartDate){
if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
if ($validateStartDate) {
if ($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
$valid = false;
}
// if edit action, check if original show start time is in the past. CC-3864
if($originalStartDate){
if($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) {
if ($originalStartDate) {
if ($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) {
$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_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($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'));
$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) {
$hours = $matches[1];
$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'));
$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)) {
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
$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'));
$valid = false;
}
}
else {
} else {
$valid = false;
}
@ -188,11 +188,11 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
*/
if (!$overlapping) {
$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;
$repeatShowEnd = clone $show_end;
$daysAdd=0;
if ($startDow !== $day){
if ($startDow !== $day) {
if ($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
@ -263,34 +263,31 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
return $valid;
}
public function disable(){
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
public function disableRepeatCheckbox(){
public function disableRepeatCheckbox()
{
$element = $this->getElement('add_show_repeats');
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
public function disableStartDateAndTime(){
public function disableStartDateAndTime()
{
$elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time'));
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
}

View file

@ -27,15 +27,13 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
$this->addElement($hosts);
}
public function disable(){
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
}

View file

@ -92,13 +92,14 @@ class Application_Form_AddUser extends Zend_Form
$this->addElement($submit);
}
public function validateLogin($data){
if (strlen($data['user_id']) == 0){
public function validateLogin($data)
{
if (strlen($data['user_id']) == 0) {
$count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
if ($count != 0){
if ($count != 0) {
$this->getElement('login')->setErrors(array("Login name is not unique."));
return false;
}
}
@ -106,4 +107,3 @@ class Application_Form_AddUser extends Zend_Form
return true;
}
}

View file

@ -151,6 +151,4 @@ class Application_Form_EditAudioMD extends Zend_Form
));
}
}

View file

@ -108,6 +108,4 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
}
}

View file

@ -14,7 +14,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
));
$defaultFade = Application_Model_Preference::GetDefaultFade();
if($defaultFade == ""){
if ($defaultFade == "") {
$defaultFade = '0.500000';
}
@ -70,7 +70,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$this->addElement($week_start_day);
}
private function getTimezones(){
private function getTimezones()
{
$regions = array(
'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
@ -86,9 +87,9 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$tzlist = array();
foreach ($regions as $name => $mask){
foreach ($regions as $name => $mask) {
$ids = DateTimeZone::listIdentifiers($mask);
foreach ($ids as $id){
foreach ($ids as $id) {
$tzlist[$id] = str_replace("_", " ", $id);
}
}
@ -96,8 +97,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
return $tzlist;
}
private function getWeekStartDays() {
private function getWeekStartDays()
{
$days = array(
'Sunday',
'Monday',
@ -107,7 +108,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
'Friday',
'Saturday'
);
return $days;
}
}

View file

@ -11,7 +11,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
if($defaultFade == ""){
if ($defaultFade == "") {
$defaultFade = '00.000000';
}
@ -50,9 +50,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($master_username);
//Master password
if($isDemo){
if ($isDemo) {
$master_password = new Zend_Form_Element_Text('master_password');
}else{
} else {
$master_password = new Zend_Form_Element_Password('master_password');
$master_password->setAttrib('renderPassword','true');
}
@ -121,19 +121,18 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($live_dj_mount);
}
// demo only code
if(!$isStreamConfigable){
if (!$isStreamConfigable) {
$elements = $this->getElements();
foreach ($elements as $element)
{
if ($element->getType() != 'Zend_Form_Element_Hidden')
{
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib("disabled", "disabled");
}
}
}
}
public function updateVariables(){
public function updateVariables()
{
global $CC_CONFIG;
$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;
$isValid = parent::isValid($data);
if (!$isSaas) {
$master_harbor_input_port = $data['master_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->addError("You cannot use same port as Master DJ port.");
}
if($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 != "") {
if (is_numeric($master_harbor_input_port)) {
if ($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()) {
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($sock, 0, $master_harbor_input_port);
if(!$res){
if (!$res) {
$element = $this->getElement("master_harbor_input_port");
$element->addError("Port '$master_harbor_input_port' is not available.");
$isValid = false;
}
socket_close($sock);
}
}else{
} else {
$isValid = false;
}
}
if($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 != "") {
if (is_numeric($dj_harbor_input_port)) {
if ($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()) {
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($sock, 0, $dj_harbor_input_port);
if(!$res){
if (!$res) {
$element = $this->getElement("dj_harbor_input_port");
$element->addError("Port '$dj_harbor_input_port' is not available.");
$isValid = false;
}
socket_close($sock);
}
}else{
} else {
$isValid = false;
}
}
}
return $isValid;
}

View file

@ -45,10 +45,10 @@ class Application_Form_Login extends Zend_Form
));
$recaptchaNeeded = false;
if(Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3){
if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) {
$recaptchaNeeded = true;
}
if($recaptchaNeeded){
if ($recaptchaNeeded) {
// recaptcha
$this->addRecaptcha();
}
@ -65,7 +65,8 @@ class Application_Form_Login extends Zend_Form
}
public function addRecaptcha(){
public function addRecaptcha()
{
$pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG';
$privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv';
@ -84,6 +85,4 @@ class Application_Form_Login extends Zend_Form
$this->addElement($captcha);
}
}

View file

@ -13,7 +13,7 @@ class Application_Form_RegisterAirtime extends Zend_Form
$country_list = Application_Model_Preference::GetCountryList();
$privacyChecked = false;
if(Application_Model_Preference::GetPrivacyPolicyCheck() == 1){
if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) {
$privacyChecked = true;
}
@ -151,17 +151,17 @@ class Application_Form_RegisterAirtime extends Zend_Form
public function isValid ($data)
{
$isValid = parent::isValid($data);
if($data['Publicise'] != 1){
if ($data['Publicise'] != 1) {
$isValid = true;
}
if(isset($data["Privacy"])){
if (isset($data["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.");
$isValid = false;
}
}
return $isValid;
}
}

View file

@ -8,6 +8,4 @@ class Application_Form_ScheduleShow extends Zend_Form
/* Form Elements & Other Definitions Here ... */
}
}

View file

@ -67,7 +67,6 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
$endTime->setAttrib('alt', 'time');
$this->addElement($endTime);
// add a select to choose a show.
$showSelect = new Zend_Form_Element_Select("sb_show_filter");
$showSelect->setLabel("Show:");
@ -84,8 +83,8 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
}
}
private function getShowNames() {
private function getShowNames()
{
$showNames = array("0" => "-------------------------");
$shows = CcShowQuery::create()

View file

@ -84,8 +84,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
"items" => "items"
);
public function init(){
public function init()
{
}
public function startForm($p_blockId, $p_isValid = false)
@ -98,7 +98,6 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$blockType = 1;
}
$spType = new Zend_Form_Element_Radio('sp_type');
$spType->setLabel('Set smart block type:')
->setDecorators(array('viewHelper'))
@ -174,13 +173,13 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$criteriaModifers->setAttrib('disabled', 'disabled');
}
if (isset($criteriaKeys[$i])) {
if($criteriaType == "s"){
if ($criteriaType == "s") {
$criteriaModifers->setMultiOptions($this->stringCriteriaOptions);
}else{
} else {
$criteriaModifers->setMultiOptions($this->numericCriteriaOptions);
}
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
}else{
} else {
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
}
$this->addElement($criteriaModifers);
@ -189,7 +188,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j);
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
->setDecorators(array('viewHelper'));
if ($i != 0 && !isset($criteriaKeys[$i])){
if ($i != 0 && !isset($criteriaKeys[$i])) {
$criteriaValue->setAttrib('disabled', 'disabled');
}
if (isset($criteriaKeys[$i])) {
@ -204,7 +203,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
}else{
} else {
$criteriaExtra->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaExtra);
@ -267,14 +266,15 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
));
}
function preValidation($params) {
public function preValidation($params)
{
$data = Application_Model_Block::organizeSmartPlyalistCriteria($params['data']);
// add elelments that needs to be added
// set multioption for modifier according to creiteria_field
$modRowMap = array();
foreach ($data['criteria'] as $critKey=>$d) {
$count = 1;
foreach($d as $modKey=>$modInfo) {
foreach ($d as $modKey=>$modInfo) {
if ($modKey == 0) {
$eleCrit = $this->getElement("sp_criteria_field_".$critKey."_".$modKey);
$eleCrit->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]);
@ -284,7 +284,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
if ($criteriaType == "s") {
$eleMod->setMultiOptions($this->stringCriteriaOptions);
} else if ($criteriaType == "n") {
} elseif ($criteriaType == "n") {
$eleMod->setMultiOptions($this->numericCriteriaOptions);
} else {
$eleMod->setMultiOptions(array('0' => 'Select modifier'));
@ -322,7 +322,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
if ($criteriaType == "s") {
$criteriaModifers->setMultiOptions($this->stringCriteriaOptions);
} else if ($criteriaType == "n") {
} elseif ($criteriaType == "n") {
$criteriaModifers->setMultiOptions($this->numericCriteriaOptions);
} else {
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
@ -344,7 +344,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
if (isset($modInfo['sp_criteria_extra'])) {
$criteriaExtra->setValue($modInfo['sp_criteria_extra']);
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
}else{
} else {
$criteriaExtra->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaExtra);
@ -368,10 +368,12 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
}
$this->populate($formData);
return $data;
}
function isValid($params){
public function isValid($params)
{
$isValid = true;
$data = $this->preValidation($params);
$criteria2PeerMap = array(
@ -433,10 +435,10 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
$element->addError("Limit cannot be empty or smaller than 0");
$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");
$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");
$isValid = false;
}
@ -446,11 +448,11 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
if (isset($data['criteria'])) {
foreach ($data['criteria'] as $rowKey=>$row) {
foreach ($row as $key=>$d){
foreach ($row as $key=>$d) {
$element = $this->getElement("sp_criteria_field_".$rowKey."_".$key);
$error = array();
// 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");
$isValid = false;
} else {
@ -461,7 +463,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$element->addError("'Length' should be in '00:00:00' format");
$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'])) {
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
$isValid = false;
@ -487,7 +489,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
}
}
}
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
} elseif ($column->getType() == PropelColumnTypes::INTEGER) {
if (!is_numeric($d['sp_criteria_value'])) {
$element->addError("The value has to be numeric");
$isValid = false;
@ -497,7 +499,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$element->addError("The value should be less then 2147483648");
$isValid = false;
}
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
} elseif ($column->getType() == PropelColumnTypes::VARCHAR) {
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
$element->addError("The value should be less ".$column->getSize()." characters");
$isValid = false;
@ -512,6 +514,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
}//end foreach
}//for loop
}//if
return $isValid;
}
}

View file

@ -149,6 +149,4 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
$this->addElement($select);
}
}

View file

@ -9,19 +9,21 @@ class Application_Form_StreamSetting extends Zend_Form
}
public function setSetting($setting){
public function setSetting($setting)
{
$this->setting = $setting;
}
public function startFrom() {
public function startFrom()
{
$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->setLabel('Hardware Audio Output')
->setRequired(false)
->setValue(($setting['output_sound_device'] == "true")?1:0)
->setDecorators(array('ViewHelper'));
if (Application_Model_Preference::GetEnableStreamConf() == "false"){
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
$output_sound_device->setAttrib("readonly", true);
}
$this->addElement($output_sound_device);
@ -32,7 +34,7 @@ class Application_Form_StreamSetting extends Zend_Form
->setMultiOptions($output_types)
->setValue($setting['output_sound_device_type'])
->setDecorators(array('ViewHelper'));
if($setting['output_sound_device'] != "true"){
if ($setting['output_sound_device'] != "true") {
$output_type->setAttrib("disabled", "disabled");
}
$this->addElement($output_type);
@ -43,7 +45,7 @@ class Application_Form_StreamSetting extends Zend_Form
->setRequired(false)
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
->setDecorators(array('ViewHelper'));
if (Application_Model_Preference::GetEnableStreamConf() == "false"){
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
$icecast_vorbis_metadata->setAttrib("readonly", true);
}
$this->addElement($icecast_vorbis_metadata);
@ -58,18 +60,20 @@ class Application_Form_StreamSetting extends Zend_Form
$this->addElement($stream_format);
}
public function isValid($data){
if(isset($data['output_sound_device'])){
public function isValid($data)
{
if (isset($data['output_sound_device'])) {
$d = array();
$d["output_sound_device"] = $data['output_sound_device'];
$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["streamFormat"] = $data['streamFormat'];
$this->populate($d);
}
$isValid = parent::isValid($data);
return $isValid;
}
}

View file

@ -1,5 +1,6 @@
<?php
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
{
private $prefix;
private $setting;
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;
}
public function setSetting($setting){
public function setSetting($setting)
{
$this->setting = $setting;
}
public function setStreamTypes($stream_types){
public function setStreamTypes($stream_types)
{
$this->stream_types = $stream_types;
}
public function setStreamBitrates($stream_bitrates){
public function setStreamBitrates($stream_bitrates)
{
$this->stream_bitrates = $stream_bitrates;
}
public function startForm(){
public function startForm()
{
$prefix = "s".$this->prefix;
$stream_number = $this->prefix;
$setting = $this->setting;
@ -36,16 +42,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$this->setIsArray(true);
$this->setElementsBelongTo($prefix."_data");
$disable_all = false;
if(Application_Model_Preference::GetEnableStreamConf() == "false"){
$disable_all = true;
}
$disable_all = Application_Model_Preference::GetEnableStreamConf() == "false";
$enable = new Zend_Form_Element_Checkbox('enable');
$enable->setLabel('Enabled:')
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$enable->setAttrib("disabled", "disabled");
}
$this->addElement($enable);
@ -55,7 +58,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setMultiOptions($stream_types)
->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0)
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$type->setAttrib("disabled", "disabled");
}
$this->addElement($type);
@ -65,7 +68,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setMultiOptions($stream_bitrates)
->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0)
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$bitrate->setAttrib("disabled", "disabled");
}
$this->addElement($bitrate);
@ -75,7 +78,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast"))
->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$output->setAttrib("disabled", "disabled");
}
$this->addElement($output);
@ -86,7 +89,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$host->setAttrib("disabled", "disabled");
}
$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))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$port->setAttrib("disabled", "disabled");
}
$this->addElement($port);
@ -109,7 +112,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$pass->setAttrib("disabled", "disabled");
}
$pass->setAttrib('alt', 'regular_text');
@ -119,7 +122,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$genre->setLabel("Genre")
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$genre->setAttrib("disabled", "disabled");
}
$this->addElement($genre);
@ -130,7 +133,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$url->setAttrib("disabled", "disabled");
}
$url->setAttrib('alt', 'url');
@ -140,7 +143,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$name->setLabel("Name")
->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$name->setAttrib("disabled", "disabled");
}
$this->addElement($name);
@ -149,7 +152,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$description->setLabel("Description")
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$description->setAttrib("disabled", "disabled");
}
$this->addElement($description);
@ -160,7 +163,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$mount->setAttrib("disabled", "disabled");
}
$mount->setAttrib('alt', 'regular_text');
@ -172,7 +175,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$user->setAttrib("disabled", "disabled");
}
$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"];
$isValid = parent::isValid($f_data);
if($f_data['enable'] == 1){
if($f_data['host'] == ''){
if ($f_data['enable'] == 1) {
if ($f_data['host'] == '') {
$element = $this->getElement("host");
$element->addError("Server cannot be empty.");
$isValid = false;
}
if($f_data['port'] == ''){
if ($f_data['port'] == '') {
$element = $this->getElement("port");
$element->addError("Port cannot be empty.");
$isValid = false;
}
if($f_data['output'] == 'icecast'){
if($f_data['mount'] == ''){
if ($f_data['output'] == 'icecast') {
if ($f_data['mount'] == '') {
$element = $this->getElement("mount");
$element->addError("Mount cannot be empty with Icecast server.");
$isValid = false;
}
}
}
return $isValid;
}
}

View file

@ -109,7 +109,7 @@ class Application_Form_SupportSettings extends Zend_Form
$upload->setAttrib('accept', 'image/*');
$this->addElement($upload);
if(!$isSass){
if (!$isSass) {
//enable support feedback
$this->addElement('checkbox', 'SupportFeedback', array(
'label' => 'Send support feedback',
@ -126,7 +126,7 @@ class Application_Form_SupportSettings extends Zend_Form
->setRequired(false)
->setDecorators(array('ViewHelper'))
->setValue(Application_Model_Preference::GetPublicise());
if(Application_Model_Preference::GetSupportFeedback() == '0'){
if (Application_Model_Preference::GetSupportFeedback() == '0') {
$checkboxPublicise->setAttrib("disabled", "disabled");
}
$this->addElement($checkboxPublicise);
@ -165,19 +165,19 @@ class Application_Form_SupportSettings extends Zend_Form
public function isValid ($data)
{
$isValid = parent::isValid($data);
if(!$this->isSass){
if($data['Publicise'] != 1){
if (!$this->isSass) {
if ($data['Publicise'] != 1) {
$isValid = true;
}
if(isset($data["Privacy"])){
if (isset($data["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.");
$isValid = false;
}
}
}
return $isValid;
}
}

View file

@ -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);
if (!is_dir($element->getValue())) {
$element->setErrors(array('Not a valid Directory'));
return false;
}
else {
} else {
$element->setValue("");
return true;
}
}
}

View file

@ -1,7 +1,9 @@
<?php
class Zend_Filter_ImageSize implements Zend_Filter_Interface {
public function filter($value) {
class Zend_Filter_ImageSize implements Zend_Filter_Interface
{
public function filter($value)
{
if (!file_exists($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;
}
}
?>

View file

@ -3,8 +3,8 @@
/**
* 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';
protected $_messageTemplates = array(
@ -43,7 +43,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
}
if (is_array($context)) {
foreach($this->_fieldValues as $fieldName=>$fieldValue) {
foreach ($this->_fieldValues as $fieldName=>$fieldValue) {
if (!isset($context[$fieldName]) || $context[$fieldName] != $fieldValue) {
return true;
}
@ -55,8 +55,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
}
$this->_error(self::KEY_IS_EMPTY);
return false;
}
}
?>

View file

@ -1,6 +1,7 @@
<?php
class PasswordNotEmpty extends ConditionalNotEmpty {
class PasswordNotEmpty extends ConditionalNotEmpty
{
public function isValid($value, $context = null)
{
$result = parent::isValid($value, $context);
@ -11,8 +12,7 @@ class PasswordNotEmpty extends ConditionalNotEmpty {
return true;
}
}
return $result;
}
}
?>