Пример #1
0
 public function actionOptions()
 {
     $cors = $this->_request->getHeader('Access-Control-Request-Method');
     if (!empty($cors)) {
         return $this->responseData('bdApi_ViewApi_Helper_Options');
     }
     $action = $this->_input->filterSingle('action', XenForo_Input::STRING);
     $action = str_replace(array('-', '/'), ' ', utf8_strtolower($action));
     $action = str_replace(' ', '', utf8_ucwords($action));
     $methods = array();
     /* @var $fc XenForo_FrontController */
     $fc = XenForo_Application::get('_bdApi_fc');
     XenForo_Application::set('_bdApi_disableBatch', true);
     foreach (array('Get', 'Post', 'Put') as $method) {
         $controllerMethod = sprintf('action%s%s', $method, $action);
         if (is_callable(array($this, $controllerMethod))) {
             $method = utf8_strtoupper($method);
             $methods[$method] = array();
             bdApi_Input::bdApi_resetFilters();
             $routeMatch = new XenForo_RouteMatch($this->_routeMatch->getControllerName(), sprintf('%s-%s', $method, $action));
             try {
                 $fc->dispatch($routeMatch);
             } catch (Exception $e) {
                 // ignore
             }
             $params = bdApi_Input::bdApi_getFilters();
             foreach (array_keys($params) as $paramKey) {
                 if (in_array($paramKey, array('fields_include', 'fields_exclude', 'limit', 'locale', 'page'), true)) {
                     // system wide params, ignore
                     unset($params[$paramKey]);
                     continue;
                 }
                 if (!isset($_GET[$paramKey]) && $this->_input->inRequest($paramKey)) {
                     // apparently this param is set by the route class
                     unset($params[$paramKey]);
                     continue;
                 }
             }
             ksort($params);
             $methods[$method]['parameters'] = array_values($params);
         }
     }
     $allowedMethods = array_keys($methods);
     $allowedMethods[] = 'OPTIONS';
     $this->_response->setHeader('Allow', implode(',', $allowedMethods));
     return $this->responseData('bdApi_ViewApi_Helper_Options', $methods);
 }
Пример #2
0
 public static function getUploadedFiles($formField, array $source = null)
 {
     bdApi_Input::bdApi_addFile($formField);
     return parent::getUploadedFiles($formField, $source);
 }
Пример #3
0
 public static function bdApi_resetFilters()
 {
     self::$_bdApi_filters = array();
 }