/** * Test the getInput method. */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat( $form->load('<form><field name="media" type="media" /></form>'), $this->isTrue(), 'Line:'.__LINE__.' XML string should load successfully.' ); $field = new JFormFieldMedia($form); $this->assertThat( $field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:'.__LINE__.' The setup method should return true.' ); $this->markTestIncomplete('Problems encountered in next assertion'); $this->assertThat( strlen($field->input), $this->greaterThan(0), 'Line:'.__LINE__.' The getInput method should return something without error.' ); // TODO: Should check all the attributes have come in properly. }
</div> </div> <div class="control-group"> <label for="image_field" class="control-label"> <?php echo JText::_('COM_AKEEBASUBS_LEVEL_FIELD_IMAGE'); ?> </label> <div class="controls"> <?php $fake_data = '<field name="image" type="media" directory="images" />'; $fakeElement = new SimpleXMLElement($fake_data); $fakeForm = new JForm('fakeForm'); $media = new JFormFieldMedia($fakeForm); $media->setup($fakeElement, $this->item->image); echo $media->input; ?> </div> </div> <div class="control-group"> <label for="enabled" class="control-label"> <?php echo JText::_('JPUBLISHED'); ?> </label> <div class="controls"> <?php echo JHTML::_('select.booleanlist', 'enabled', null, $this->item->enabled); ?>
/** * Creating rows with input fields * * @param string $text * @param string $name * @param string $value */ public static function image($name, $value, $class = 'class="inputbox"', $readonly = '', $size = '30', $maxlength = '255', $more = '') { require_once JPATH_ROOT . '/libraries/cms/form/field/media.php'; $media_field = new JFormFieldMedia(); $media_string = <<<XML <field name="{$name}" type="media" default="1" label=""> </field> XML; $element_media = simplexml_load_string($media_string); $media_field->setup($element_media, $value, ''); return $media_field->renderField(); }