SAAS-290: Hosted SaaS widgets + javascript code generation

This commit is contained in:
Martin Konecny 2012-11-06 18:10:53 -05:00
parent 272e428fa7
commit 27d40ef4df
2 changed files with 53 additions and 0 deletions

View file

@ -48,6 +48,18 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
$third_party_api->setDecorators(array('ViewHelper'));
$this->addElement($third_party_api);
//
// Add the description element
$this->addElement('textarea', 'widgetCode', array(
'label' => 'Javascript Code:',
'required' => false,
'readonly' => true,
'class' => 'input_text_area',
'value' => self::getWidgetCode(), //$_SERVER["SERVER_NAME"],
'decorators' => array(
'ViewHelper'
)
));
/* Form Element for setting the Timezone */
$timezone = new Zend_Form_Element_Select("timezone");
@ -93,6 +105,33 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
return $tzlist;
}
private static function getWidgetCode() {
$code = <<<CODE
$("#headerLiveHolder").airtimeLiveInfo({
sourceDomain: "http://{$_SERVER['SERVER_NAME']}",
text: {onAirNow:"On Air Now", offline:"Offline", current:"Current", next:"Next"},
updatePeriod: 20 //seconds
});
$("#onAirToday").airtimeShowSchedule({
sourceDomain: "http://{$_SERVER['SERVER_NAME']}",
text: {onAirToday:"On air today"},
updatePeriod: 5, //seconds
showLimit: 10
});
$("#scheduleTabs").airtimeWeekSchedule({
sourceDomain:"http://{$_SERVER['SERVER_NAME']}",
dowText:{monday:"Monday", tuesday:"Tuesday", wednesday:"Wednesday", thursday:"Thursday", friday:"Friday", saturday:"Saturday", sunday:"Sunday"},
miscText:{time:"Time", programName:"Program Name", details:"Details", readMore:"Read More"},
updatePeriod: 600 //seconds
});
CODE;
return $code;
}
private function getWeekStartDays()
{
$days = array(

View file

@ -50,6 +50,20 @@
</ul>
<?php endif; ?>
</dd>
<dt id="widgetCode-label" class="block-display">
<label class="optional" for="widgetCode"><?php echo $this->element->getElement('widgetCode')->getLabel() ?></label>
</dt>
<dd id="widgetCode-element" class="block-display clearfix">
<?php echo $this->element->getElement('widgetCode') ?>
<?php if($this->element->getElement('widgetCode')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('widgetCode')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="timezone-label" class="block-display">
<label class="required" for="timezone"><?php echo $this->element->getElement('timezone')->getLabel() ?>
<span class="info-text-small">(Required)</span> :