Example #1
0
 /**
  * UI hook to remove all source input selections and replace them by a set
  * of radio buttons allowing the user to select the requested size
  */
 public static function onUploadFormSourceDescriptors(&$descriptor, &$radio, $selectedSourceType)
 {
     global $wgRequest;
     if ($wgRequest->getVal('wpSourceType') != 'IFI' || !$wgRequest->getCheck('wpFlickrId')) {
         return true;
     }
     // We entered here from Special:ImportFreeImages, so kill all other source selections
     foreach ($descriptor as $name => $value) {
         if (isset($value['section']) && $value['section'] == 'source') {
             unset($descriptor[$name]);
         }
     }
     $ifi = new ImportFreeImages();
     $sizes = $ifi->getSizes($wgRequest->getText('wpFlickrId'));
     // Create radio buttons. TODO: Show resolution; Make largest size default
     $options = array();
     foreach ($sizes as $size) {
         $label = wfMsgExt('importfreeimages_size_' . strtolower($size['label']), 'parseinline');
         $options[$label] = $size['label'];
     }
     $descriptor['Size'] = array('type' => 'radio', 'section' => 'source', 'name' => 'Size', 'options' => $options);
     $descriptor['wpFlickrId'] = array('type' => 'hidden', 'name' => 'wpFlickrId', 'default' => $wgRequest->getText('wpFlickrId'));
     $descriptor['wpSourceType'] = array('type' => 'hidden', 'name' => 'wpSourceType', 'default' => 'IFI');
     // Stop running further hooks
     return false;
 }