static function display_format($ad, $nw = false) { $properties = $ad->get_network_property_defaults(); if (isset($properties['adtype'])) { $adtype = $nw ? $ad->get_network_property('adtype') : $ad->get_property('adtype'); } else { $adtype = null; } $adformat = $nw ? $ad->get_network_property('adformat') : $ad->get_property('adformat'); $width = $nw ? $ad->get_network_property('width') : $ad->get_property('width'); $height = $nw ? $ad->get_network_property('height') : $ad->get_property('height'); $formats = Advman_Tools::organize_formats($ad->get_ad_formats()); ?> <table class="form-table" id="advman-settings-ad_format"> <?php if (!is_null($adtype)) { if (sizeof($formats['data']) == 1) { foreach ($formats['data'] as $t => $sectionFormat) { ?> ?><input type="hidden" name="advman-adtype" value="<?php echo $t; ?> "> <?php } } else { ?> <tr id="advman-form-adtype"> <td class="advman_label"><label for="advman-adtype"><?php _e('Ad Type:'); ?> </label></td> <td> <select name="advman-adtype" id="advman-adtype" onchange="advman_form_update(this);"> <option value=""> <?php _e('Use Default', 'advman'); ?> </option> <?php foreach ($formats['data'] as $t => $sectionFormat) { ?> <option<?php echo $adtype == $t ? ' selected="selected"' : ''; ?> value="<?php echo $t; ?> "> <?php echo $formats['types'][$t]; ?> </option> <?php } ?> </select> <img class="default_note" title="<?php echo __('[Default]', 'advman') . ' ' . $ad->get_network_property('adtype'); ?> "> </td> </tr> <?php } } foreach ($formats['data'] as $t => $sectionFormats) { ?> <tr id="advman-form-adformat-<?php echo $t; ?> "<?php echo $t == $adtype || is_null($adtype) ? '' : ' style="display:none"'; ?> > <td class="advman_label"><label for="advman-adformat"><?php _e('Format:', 'advman'); ?> </label></td> <td> <select name="advman-adformat<?php echo is_null($adtype) ? '' : '-' . $t; ?> " id="advman-adformat" onchange="advman_form_update(this);"> <?php if (!$nw) { ?> <optgroup id="advman-optgroup-default" label="<?php _e('Default', 'advman'); ?> "> <option value=""> <?php _e('Use Default', 'advman'); ?> </option> </optgroup> <?php } foreach ($sectionFormats as $section => $sformats) { ?> <optgroup id="advman-optgroup-<?php echo $section; ?> " label="<?php echo $formats['sections'][$section]; ?> "> <?php foreach ($sformats as $sformat) { list($w, $h, $l) = OX_Tools::explode_format($sformat); ?> <option<?php echo $adformat == $sformat ? ' selected="selected"' : ''; ?> value="<?php echo $sformat; ?> "> <?php printf($formats['formats'][$sformat], $w, $h, $l); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> <img class="default_note" title="<?php echo __('[Default]', 'advman') . ' ' . $ad->get_network_property('adformat'); ?> "> </td> </tr> <?php } if (!empty($formats['sections']['custom'])) { ?> <tr id="advman-settings-custom"> <td class="advman_label"><label for="advman-width"><?php _e('Dimensions:'); ?> </label></td> <td> <input name="advman-width" size="5" title="<?php _e('Custom width for this unit.', 'advman'); ?> " value="<?php echo $width; ?> " /> x <input name="advman-height" size="5" title="<?php _e('Custom height for this unit.', 'advman'); ?> " value="<?php echo $height; ?> " /> px </td> </tr> <?php } ?> </table> <br /> <span style="font-size:x-small;color:gray;"><?php _e('Select one of the supported ad format sizes.', 'advman'); ?> <?php if (!empty($formats['sections']['custom'])) { _e('If your ad size is not one of the standard sizes, select Custom and fill in your size.', 'advman'); } ?> </span> <?php }
public function testExplodeFormat() { list($a, $b) = OX_Tools::explode_format('728x90'); $this->assertEquals($a, 728); $this->assertEquals($b, 90); }