/**
  * validate
  *
  * @return bool Returns true if input parameters are valid
  */
 public function validate()
 {
     switch ($this->_params['action']) {
         case 'importEvents':
             $expected = array('optional' => array('period', 'callback'), 'alphanum' => array('period', 'callback'));
             break;
         case 'getEvent':
             $expected = array('optional' => array('id', 'kb_archivid'));
             break;
         case 'getEvents':
             $expected = array('required' => array('startTime'), 'optional' => array('eventType', 'cacheOnly', 'force', 'ar_filter'), 'bools' => array('cacheOnly', 'force', 'ar_filter'), 'dates' => array('startTime'));
             break;
         case 'getEventsByEventLayers':
             $expected = array('required' => array('startTime', 'eventLayers'), 'optional' => array('ar_filter'), 'bools' => array('ar_filter'), 'dates' => array('startTime'));
             break;
         case 'getEventFRMs':
             $expected = array('required' => array('startTime'), 'optional' => array('ar_filter'), 'bools' => array('ar_filter'), 'dates' => array('startTime'));
             break;
         case 'getFRMs':
             $expected = array('required' => array('startTime', 'endTime'), 'dates' => array('startTime', 'endTime'));
             break;
         default:
             break;
     }
     // Check input
     if (isset($expected)) {
         Validation_InputValidator::checkInput($expected, $this->_params, $this->_options);
     }
     return true;
 }
 /**
  * Checks an array of UTC dates
  *
  * @param array $dates   dates to check
  * @param array &$params The parameters that were passed in
  *
  * @return void
  */
 public static function checkDates($dates, &$params)
 {
     foreach ($dates as $date) {
         if (isset($params[$date])) {
             Validation_InputValidator::checkUTCDate($params[$date]);
         }
     }
 }
 /**
  * Handles input validation
  *
  * @return bool Returns true if the input is valid with respect to the
  *              requested action.
  */
 public function validate()
 {
     switch ($this->_params['action']) {
         case 'downloadScreenshot':
             $expected = array('required' => array('id'), 'optional' => array('force'), 'ints' => array('id'), 'bools' => array('force'));
             break;
         case 'getClosestImage':
             $expected = array('dates' => array('date'), 'optional' => array('callback'), 'alphanum' => array('callback'));
             $expected = array_merge($expected, array('required' => array('date', 'sourceId'), 'ints' => array('sourceId')));
             break;
         case 'getDataSources':
             $expected = array('optional' => array('verbose', 'callback', 'enable'), 'bools' => array('verbose'), 'alphanum' => array('callback'));
             break;
         case 'getTile':
             $expected = array('required' => array('id', 'x', 'y', 'imageScale'), 'floats' => array('imageScale'), 'ints' => array('id', 'x', 'y'));
             break;
         case 'getJP2Header':
             $expected = array('required' => array('id'), 'ints' => array('id'), 'optional' => array('callback'), 'alphanum' => array('callback'));
             break;
         case 'getNewsFeed':
             $expected = array('optional' => array('callback'), 'alphanum' => array('callback'));
             break;
         case 'getUsageStatistics':
             $expected = array('optional' => array('resolution', 'callback'), 'alphanum' => array('resolution', 'callback'));
             break;
         case 'getDataCoverage':
             $expected = array('optional' => array('resolution', 'currentDate', 'startDate', 'endDate', 'callback', 'imageLayers', 'startDate', 'endDate', 'eventLayers'), 'alphanum' => array('resolution', 'callback'), 'dates' => array());
             break;
         case 'updateDataCoverage':
             $expected = array('optional' => array('period', 'callback'), 'alphanum' => array('period', 'callback'));
             break;
         case 'shortenURL':
             $expected = array('required' => array('queryString'), 'optional' => array('callback'), 'encoded' => array('queryString', 'callback'));
             break;
         case 'takeScreenshot':
             $expected = array('required' => array('date', 'imageScale', 'layers'), 'optional' => array('display', 'watermark', 'x1', 'x2', 'y1', 'y2', 'x0', 'y0', 'width', 'height', 'events', 'eventLabels', 'scale', 'scaleType', 'scaleX', 'scaleY', 'callback'), 'floats' => array('imageScale', 'x1', 'x2', 'y1', 'y2', 'x0', 'y0', 'scaleX', 'scaleY'), 'ints' => array('width', 'height'), 'dates' => array('date'), 'bools' => array('display', 'watermark', 'eventLabels', 'scale'), 'alphanum' => array('scaleType', 'callback'));
             break;
         case 'getStatus':
             $expected = array('optional' => array('key'), 'alphanum' => array('key'));
         case "getSciDataScript":
             $expected = array("required" => array('imageScale', 'sourceIds', 'startDate', 'endDate', 'lang', 'provider'), "optional" => array('x0', 'y0', 'width', 'height', 'x1', 'y1', 'x2', 'y2', 'callback'), "floats" => array('imageScale', 'x0', 'y0', 'x1', 'y1', 'x2', 'y2'), "ints" => array('width', 'height'), "dates" => array('startDate', 'endDate'), "alphanum" => array('provider', 'callback'));
             break;
         default:
             break;
     }
     if (isset($expected)) {
         Validation_InputValidator::checkInput($expected, $this->_params, $this->_options);
     }
     return true;
 }
Exemple #4
0
 /**
  * validate
  *
  * @return bool Returns true if input parameters are valid
  */
 public function validate()
 {
     switch ($this->_params['action']) {
         case 'downloadMovie':
             $expected = array('required' => array('id', 'format'), 'optional' => array('hq'), 'alphanum' => array('id', 'format'), 'bools' => array('hq'));
             break;
         case 'getMovieStatus':
             $expected = array('required' => array('id', 'format'), 'optional' => array('verbose', 'callback', 'token'), 'alphanum' => array('id', 'format', 'callback', 'token'), 'bools' => array('verbose'));
             break;
         case 'playMovie':
             $expected = array('required' => array('id', 'format'), 'optional' => array('hq', 'width', 'height'), 'alphanum' => array('id', 'format'), 'bools' => array('hq'), 'ints' => array('width', 'height'));
             break;
         case 'queueMovie':
             $expected = array('required' => array('startTime', 'endTime', 'layers', 'events', 'eventsLabels', 'imageScale'), 'optional' => array('format', 'frameRate', 'maxFrames', 'scale', 'scaleType', 'scaleX', 'scaleY', 'movieLength', 'watermark', 'width', 'height', 'x0', 'y0', 'x1', 'x2', 'y1', 'y2', 'callback'), 'alphanum' => array('format', 'scaleType', 'callback'), 'bools' => array('watermark', 'eventsLabels', 'scale'), 'dates' => array('startTime', 'endTime'), 'floats' => array('imageScale', 'frameRate', 'movieLength', 'x0', 'y0', 'x1', 'x2', 'y1', 'y2', 'scaleX', 'scaleY'), 'ints' => array('maxFrames', 'width', 'height'));
             break;
         case 'reQueueMovie':
             $expected = array('required' => array('id'), 'optional' => array('force', 'callback'), 'alphanum' => array('id', 'callback'), 'bools' => array('force'));
             break;
         case 'uploadMovieToYouTube':
             $expected = array('optional' => array('id', 'title', 'description', 'tags', 'share', 'token', 'code', 'html'), 'alphanum' => array('id'), 'bools' => array('share', 'html'));
             break;
         case 'getUserVideos':
             $expected = array('optional' => array('num', 'skip', 'since', 'force', 'callback'), 'alphanum' => array('callback'), 'ints' => array('num', 'skip'), 'dates' => array('since'), 'bools' => array('force'));
             break;
         case 'getObservationDateVideos':
             $expected = array('optional' => array('num', 'skip', 'date', 'callback'), 'alphanum' => array('callback'), 'ints' => array('num', 'skip'), 'dates' => array('date'));
             break;
         case 'checkYouTubeAuth':
             $expected = array('optional' => array('callback'), 'alphanum' => array('callback'));
             break;
         case 'getYouTubeAuth':
             $expected = array('required' => array('id', 'title', 'description', 'tags'), 'optional' => array('share'), 'alphanum' => array('id'), 'bools' => array('share'));
         default:
             break;
     }
     // Check input
     if (isset($expected)) {
         Validation_InputValidator::checkInput($expected, $this->_params, $this->_options);
     }
     return true;
 }
 /**
  * Validate the requested action and associated input parameters.
  *
  * @return void
  */
 public function validate()
 {
     switch ($this->_params['action']) {
         case 'getJP2Image':
             $expected = array('optional' => array('jpip', 'json'), 'bools' => array('jpip', 'json'), 'dates' => array('date'));
             // If imageId is specified, that is all that is needed
             if (isset($this->_params['id'])) {
                 $expected['required'] = array('id');
                 $expected['ints'] = array('id');
             } else {
                 $expected['required'] = array('date', 'sourceId');
                 $expected['ints'] = array('sourceId');
             }
             break;
         case 'getJPX':
             $expected = array('required' => array('startTime', 'endTime'), 'optional' => array('cadence', 'jpip', 'linked', 'verbose'), 'bools' => array('jpip', 'verbose', 'linked'), 'dates' => array('startTime', 'endTime'), 'ints' => array('cadence'));
             $expected['required'] = array('startTime', 'endTime', 'sourceId');
             $expected['ints'] = array('sourceId');
             break;
         case 'getJPXClosestToMidPoint':
             $expected = array('required' => array('sourceId', 'startTimes', 'endTimes'), 'optional' => array('jpip', 'linked', 'verbose'), 'bools' => array('jpip', 'verbose', 'linked'), 'dates' => array(), 'ints' => array('sourceId'));
             break;
         case 'launchJHelioviewer':
             $expected = array('required' => array('startTime', 'endTime', 'imageScale', 'layers'), 'floats' => array('imageScale'), 'dates' => array('startTime', 'endTime'));
             break;
         default:
             break;
     }
     // end switch block
     if (isset($expected)) {
         Validation_InputValidator::checkInput($expected, $this->_params, $this->_options);
     }
     return true;
 }