Perforce Chronicle 2012.2/486814
API Documentation
|
This is the flickr stream widget config form. More...
Public Member Functions | |
init () | |
Defines the elements that make up the config form. | |
isValid ($data) | |
Ensures that the appopriate data is entered, depending on the selected image source. | |
setDefaults (array $defaults) | |
Whenever values are set on the form, show/hide the appopriate source key fieldset. | |
Public Attributes | |
const | DIMENSION_LARGE = 'Large' |
const | DIMENSION_MEDIUM = 'Medium' |
const | DIMENSION_SMALL = 'Small' |
const | DIMENSION_SQUARE = 'Square' |
const | DIMENSION_THUMBNAIL = 'Thumbnail' |
const | PAGE_SIZE = 5 |
const | SOURCE_GROUP = 'Group' |
const | SOURCE_TAG = 'Tag' |
const | SOURCE_USER = 'User' |
Static Public Attributes | |
static | $sizeDimensions |
This is the flickr stream widget config form.
Flickr_Form_StreamWidget::init | ( | ) |
Defines the elements that make up the config form.
Form controls size of image (flickr size: square, thumb, small, medium, large, original), and source (user, topic, group). Called automatically when the form object is created.
{ $types = $this->addElement( 'select', 'sourceType', array( 'label' => 'Image Source Type', 'multiOptions' => array_combine($this->_definedSources, $this->_definedSources), 'value' => $this->_defaultSource, 'onChange' => "var prefix = this.id.replace(/[^-]+-sourceType$/, '');" . "p4cms.ui.hide(prefix + 'config-streamSourceTag', {duration: 0});" . "p4cms.ui.hide(prefix + 'config-streamSourceUser', {duration: 0});" . "p4cms.ui.hide(prefix + 'config-streamSourceGroup', {duration: 0});" . "p4cms.ui.show(prefix + 'config-streamSource' + this.value);" ) ); // control visibility based on the selected source $this->addElement( 'text', 'sourceTag', array( 'label' => 'Flickr Tags') ); $this->addDisplayGroup( array('sourceTag'), 'streamSourceTag', array('style' => 'display: none;') ); $this->addElement( 'text', 'sourceUser', array('label' => 'Flickr Username') ); $this->addDisplayGroup( array('sourceUser'), 'streamSourceUser', array('style' => 'display: none;') ); $this->addElement( 'text', 'sourceGroup', array('label' => 'Flickr Group Id') ); $this->addDisplayGroup( array('sourceGroup'), 'streamSourceGroup', array('style' => 'display: none;') ); $size = $this->addElement( 'select', 'imageSize', array( 'label' => 'Image Size', 'multiOptions' => $this->_definedSizes, 'value' => $this->_defaultImageSize ) ); $this->addElement( 'checkbox', 'showImageTitle', array( 'label' => 'Show Image Title', 'value' => $this->_defaultShowTitle ) ); $this->addElement( 'text', 'imageDelay', array( 'label' => 'Image Delay (seconds)', 'value' => $this->_defaultDelay, 'validators' => array( 'digits' ) ) ); }
Flickr_Form_StreamWidget::isValid | ( | $ | data | ) |
Ensures that the appopriate data is entered, depending on the selected image source.
array | $data | the array of form submission data to validate |
{ if (!parent::isValid($data)) { return false; } $sourceKey = 'source' . $data['config']['sourceType']; if (empty($data['config'][$sourceKey])) { $this->getElement($sourceKey)->addError( "You must enter a " . $this->getElement($sourceKey)->getLabel() . "." ); return false; } return true; }
Flickr_Form_StreamWidget::setDefaults | ( | array $ | defaults | ) |
Whenever values are set on the form, show/hide the appopriate source key fieldset.
array | $defaults | the values to populate the form |
{ if (isset($defaults['config']['sourceType'])) { $fieldsetName = 'streamSource' . $defaults['config']['sourceType']; $this->getDisplayGroup($fieldsetName)->setAttrib('style', 'display: block;'); } else { $fieldsetName = 'streamSource' . $this->_defaultSource; $this->getDisplayGroup($fieldsetName)->setAttrib('style', 'display: block;'); } return parent::setDefaults($defaults); }
Flickr_Form_StreamWidget::$sizeDimensions [static] |
array( self::DIMENSION_SQUARE => 75, self::DIMENSION_THUMBNAIL => 100, self::DIMENSION_SMALL => 240, self::DIMENSION_MEDIUM => 500, self::DIMENSION_LARGE => 640 )
const Flickr_Form_StreamWidget::DIMENSION_LARGE = 'Large' |
const Flickr_Form_StreamWidget::DIMENSION_MEDIUM = 'Medium' |
const Flickr_Form_StreamWidget::DIMENSION_SMALL = 'Small' |
const Flickr_Form_StreamWidget::DIMENSION_SQUARE = 'Square' |
const Flickr_Form_StreamWidget::DIMENSION_THUMBNAIL = 'Thumbnail' |
const Flickr_Form_StreamWidget::PAGE_SIZE = 5 |
const Flickr_Form_StreamWidget::SOURCE_GROUP = 'Group' |
const Flickr_Form_StreamWidget::SOURCE_TAG = 'Tag' |
const Flickr_Form_StreamWidget::SOURCE_USER = 'User' |