Parses the query string looking for supplied request parameters. Places
anything useful into this object's Controller properties.

@param int $FolderDepth
2864
protected function AnalyzeRequest(&$Request) {
   
      // Here is the basic format of a request:
      // [/application]/controller[/method[.json|.xml]]/argn|argn=valn

      // Here are some examples of what this method could/would receive:
      // /application/controller/method/argn
      // /controller/method/argn
      // /application/controller/argn
      // /controller/argn
      // /controller

      // Clear the slate
      $this->_ApplicationFolder = '';
      $this->ControllerFolder = '';
      $this->ControllerName = '';
      $this->ControllerMethod = 'index';
      $this->_ControllerMethodArgs = array();
      $this->Request = $Request->Path(FALSE);

      $PathAndQuery = $Request->PathAndQuery();
      $MatchRoute = Gdn::Router()->MatchRoute($PathAndQuery);
      
      // We have a route. Take action.
      if ($MatchRoute !== FALSE) {
         switch ($MatchRoute['Type']) {
            case 'Internal':
               $Request->PathAndQuery($MatchRoute['FinalDestination']);
               $this->Request = $Request->Path(FALSE);
               break;

            case 'Temporary':
               header("HTTP/1.1 302 Moved Temporarily" );
               header("Location: ".Url($MatchRoute['FinalDestination']));
               exit();
               break;

            case 'Permanent':
               header("HTTP/1.1 301 Moved Permanently" );
               header("Location: ".Url($MatchRoute['FinalDestination']));
               exit();
               break;

            case 'NotAuthorized':
               header("HTTP/1.1 401 Not Authorized" );
               $this->Request = $MatchRoute['FinalDestination'];
               break;

            case 'NotFound':
               header("HTTP/1.1 404 Not Found" );
               $this->Request = $MatchRoute['FinalDestination'];
               break;
            case 'Test':
               $Request->PathAndQuery($MatchRoute['FinalDestination']);
               $this->Request = $Request->Path(FALSE);
               decho($MatchRoute, 'Route');
               decho(array(
                  'Path' => $Request->Path(),
                  'Get' => $Request->Get()
                  ), 'Request');
               die();
         }
      }
      
      switch ($Request->OutputFormat()) {
         case 'rss':
            $this->_SyndicationMethod = SYNDICATION_RSS;
            break;
         case 'atom':
            $this->_SyndicationMethod = SYNDICATION_ATOM;
            break;
         case 'default':
         default:
            $this->_SyndicationMethod = SYNDICATION_NONE;
            break;
      }

      if ($this->Request == '') {
         $DefaultController = Gdn::Router()->GetRoute('DefaultController');
         $this->Request = $DefaultController['Destination'];
      }

      $Parts = explode('/', str_replace('\\', '/', $this->Request));

      /**
       * The application folder is either the first argument or is not provided. The controller is therefore
       * either the second argument or the first, depending on the result of the previous statement. Check that.
       */
      try {
         // if the 1st argument is a valid application, check if it has a controller matching the 2nd argument
         if (in_array($Parts[0], $this->EnabledApplicationFolders()))
            $this->FindController(1, $Parts);

         // if no match, see if the first argument is a controller
         $this->FindController(0, $Parts);

         // 3] See if there is a plugin trying to create a root method.
         list($MethodName, $DeliveryMethod) = $this->_SplitDeliveryMethod(GetValue(0, $Parts), TRUE);
         if ($MethodName && Gdn::PluginManager()->HasNewMethod('RootController', $MethodName, TRUE)) {
            $this->_DeliveryMethod = $DeliveryMethod;
            $Parts[0] = $MethodName;
            $Parts = array_merge(array('root'), $Parts);
            $this->FindController(0, $Parts);
         }

         throw new GdnDispatcherControllerNotFoundException();
      } catch (GdnDispatcherControllerFoundException $e) {

         switch ($this->_DeliveryMethod) {
            case DELIVERY_METHOD_JSON:
            case DELIVERY_METHOD_XML:
               $this->_DeliveryType = DELIVERY_TYPE_DATA;
               break;
            case DELIVERY_METHOD_TEXT:
               $this->_DeliveryType = DELIVERY_TYPE_VIEW;
               break;
            case DELIVERY_METHOD_XHTML:
            case DELIVERY_METHOD_RSS:
               break;
            default:
               $this->_DeliveryMethod = DELIVERY_METHOD_XHTML;
               break;
         }

         return TRUE;
      } catch (GdnDispatcherControllerNotFoundException $e) {
         $this->EventArguments['Handled'] = FALSE;
         $Handled =& $this->EventArguments['Handled'];
         $this->FireEvent('NotFound');
         
         if (!$Handled) {
            header("HTTP/1.1 404 Not Found");
            $Request->WithRoute('Default404');
            return $this->AnalyzeRequest($Request);
         }
      }
   }
873954
private function parse()
    {
        $this->parameters   = [];
        $this->pathSegments = [];
        $parsedUrl          = parse_url($this->returnValue);
        foreach ($parsedUrl as $key => $value) {
            if ($key == 'query') {
                parse_str($value, $this->parameters);
            } elseif ($key == 'path') {
                $this->pathSegments = ($value) ? explode('/', ltrim($value, '/')) : [];
            } else {
                $this->{$key} = $value;
            }
        }
        return $this;
    }
385179
public function showFolderListAction(Request $request, ContentView $view)
    {
        $languages = $this->getConfigResolver()->getParameter('languages');

        // Using the criteria helper (a demobundle custom service) to generate our query's criteria.
        // This is a good practice in order to have less code in your controller.
        $criteria = $this->get('ezdemo.criteria_helper')->generateListFolderCriterion(
            $view->getLocation(),
            $this->container->getParameter('ezdemo.folder.folder_view.excluded_content_types'),
            $languages
        );

        // Generating query
        $query = new LocationQuery();
        $query->query = $criteria;
        $query->sortClauses = array(
            new SortClause\DatePublished(),
        );

        // Initialize pagination.
        $pager = new Pagerfanta(
            new ContentSearchAdapter($query, $this->getRepository()->getSearchService())
        );

        $pager->setMaxPerPage($this->container->getParameter('ezdemo.folder.folder_list.limit'));
        $pager->setCurrentPage($request->get('page', 1));

        $includedContentTypeIdentifiers = $this->container->getParameter('ezdemo.folder.folder_tree.included_content_types');

        // Get sub folder structure
        $subContentCriteria = $this->get('ezdemo.criteria_helper')->generateSubContentCriterion(
            $view->getLocation(), $includedContentTypeIdentifiers, $languages
        );

        $subContentQuery = new LocationQuery();
        $subContentQuery->query = $subContentCriteria;
        $subContentQuery->sortClauses = array(
            new SortClause\ContentName(),
        );

        $searchService = $this->getRepository()->getSearchService();
        $subContent = $searchService->findLocations($subContentQuery);

        $treeItems = array();
        foreach ($subContent->searchHits as $hit) {
            $treeItems[] = $hit->valueObject;
        }

        $view->addParameters(['pagerFolder' => $pager, 'treeItems' => $treeItems]);

        return $view;
    }
444489
protected function set_search_dirty($folder)
    {
        if ($this->search_set && is_a($this->search_set, 'rcube_result_multifolder')) {
            if ($subset = $this->search_set->get_set($folder)) {
                $subset->incomplete = $this->search_set->incomplete = true;
            }
        }
    }
855671
private function getURL($parameter, Request $request, $homeFolder, $path)
    {
        if (isset($parameter['url']) && $parameter['url']) {
            if (0 === strpos($parameter['url'], 'http')) {
                return $parameter['url'];
            }

            $path = $parameter['url'].'/'.$homeFolder;
        } else {
            $path = $path.'/'.$homeFolder;
        }

        return $request->getUriForPath('/'.trim($path, '/'));
    }
219748
def project_list_folder(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/listFolder' % object_id, input_params, always_retry=always_retry, **kwargs)
1224124
static function parse_str($query)
    {
        if ($query === null) {
            return null;
        }

        $parts = explode('&', $query);

        $new_parts = array();
        for ($i = 0; $i < count($parts); $i++) {
            $pair = explode('=', $parts[$i]);

            if (count($pair) != 2) {
                continue;
            }

            list($key, $value) = $pair;
            $new_parts[urldecode($key)] = urldecode($value);
        }

        return $new_parts;
    }
1254283
protected function _getParams($sRequest, $sPath)
    {
        $oStr = getStr();

        $sParams = $oStr->preg_replace('/\?.*/', '', $sRequest);
        $sPath = preg_quote($sPath, '/');
        $sParams = $oStr->preg_replace("/^$sPath/", '', $sParams);

        // this should not happen on most cases, because this redirect is handled by .htaccess
        if ($sParams && !$oStr->preg_match('/\.html$/', $sParams) && !$oStr->preg_match('/\/$/', $sParams)) {
            \OxidEsales\Eshop\Core\Registry::getUtils()->redirect(\OxidEsales\Eshop\Core\Registry::getConfig()->getShopURL() . $sParams . '/', false);
        }

        return $sParams;
    }
25407
public function folder_data($folder)
    {
        if (!strlen($folder)) {
            $folder = $this->folder !== null ? $this->folder : 'INBOX';
        }

        if ($this->conn->selected != $folder) {
            if (!$this->check_connection()) {
                return array();
            }

            if ($this->conn->select($folder)) {
                $this->folder = $folder;
            }
            else {
                return null;
            }
        }

        $data = $this->conn->data;

        // add (E)SEARCH result for ALL UNDELETED query
        if (!empty($this->icache['undeleted_idx'])
            && $this->icache['undeleted_idx']->get_parameters('MAILBOX') == $folder
        ) {
            $data['UNDELETED'] = $this->icache['undeleted_idx'];
        }

        return $data;
    }
596492
public function handleSearch(SS_HTTPRequest $request)
    {

        if ($request->getVar('search') === null) {
            return null;
        }

        $result = array();
        $searchTerm = $request->getVar('search');
        $list = File::get()->filterAny(array(
            'Title:PartialMatch' => $searchTerm,
            'Filename:PartialMatch' => $searchTerm
        ))->limit(100);

        $this->extend('beforeHandleSearch', $list, $searchTerm);

        foreach ($list as $item) {
            if (!$item->canView()) {
                continue;
            }
            $result[] = $item instanceof Folder ? $this->createFolderJson($item) : $this->createFileJson($item);
        }

        $response = new SS_HTTPResponse(
            Convert::array2json($result), 200
        );

        return $response->addHeader('Content-Type', 'application/json');
    }
508105
public static function findPhakefileParts($folder)
    {
        $result = array();

        $dir = new DirectoryIterator($folder);
        $regex = new RegexIterator($dir, '/\.php$/');
        foreach ($regex as $item) {
            $result[] = $item->getRealpath();
        }

        return $result;
    }
1180163
public function parseMethods($query, $string)
    {
        //replaces any @col(\w+) pattern with the correct column name
        if (strpos($string, '@col(')) {
            $matches = array();
            if (preg_match_all('/@col\((.*?)\)/', $string, $matches)) {
                $description = $query->getRepository()->getDescription();
                $replaces = array();
                foreach ($matches[1] as $match) {
                    $result = AnDomainQueryHelper::parseColumn($query, $match);
                    if (empty($result['columns'])) {
                        $replaces[] = $match;
                    } else {
                        $replaces[] = (string) $result['columns'];
                    }
                }

                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@quote(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/@quote\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $match) {
                    $replaces[] = $this->_store->quoteValue($match);
                }
                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@instanceof(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/\!?@instanceof\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $i => $match) {
                    $operand = '';
                    if ($matches[0][$i][0] == '!') {
                        $operand = 'NOT ';
                    }
                    $type_col = $query->getRepository()->getDescription()->getInheritanceColumn();
                    $classes = explode(',', $match);
                    $statements = array();
                    foreach ($classes as $class) {
                        $class = $this->_store->quoteValue($class);
                        $statements[] = $operand."FIND_IN_SET($class,$type_col)";
                    }
                    if ($operand == 'NOT ') {
                        $operand = ' AND ';
                    } else {
                        $operand = ' OR ';
                    }
                    if (count($statements) == 1) {
                        $statements = implode($operand, $statements);
                    } else {
                        $statements = '('.implode($operand, $statements).')';
                    }

                    $replaces[] = $statements;
                }
                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@remove_from_set(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/@remove_from_set\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $i => $match) {
                    list($set, $item) = explode(',', $match);
                    $set = trim($set);
                    $item = trim($item);
                    $replaces[] = "TRIM(BOTH ',' FROM REPLACE(concat(',',$set,','),CONCAT(',',$item,','),','))";
                }

                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@set_length(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/@set_length\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $i => $match) {
                    $replaces[] = "LENGTH($match) - LENGTH(REPLACE($match, ',', '')) + 1";
                }
                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        return $string;
    }
134501
public function parse($query=null)
    {
        $this->checkQuery($query);
        
        return $this->getDb()->setQuery($this->getQuery())->parse();
    }
71239
public function listAction(Request $request)
    {
        $folderId = $request->get('folder_id');
        $start = $request->get('start', 0);
        $limit = $request->get('limit', 25);
        $sort = $request->get('sort', 'name');
        $dir = $request->get('dir', 'ASC');
        $showHidden = $request->get('show_hidden', false);
        $filter = $request->get('filter');

        if (!$folderId) {
            throw new \RuntimeException('No folder ID');
        }

        if ($filter) {
            $filter = json_decode($filter, true);
        }

        $data = [];
        $total = 0;

        $volume = $this->getVolumeByFolderId($folderId);
        $securityContext = $this->get('security.context');

        $folder = $volume->findFolder($folderId);

        if ($securityContext->isGranted('ROLE_SUPER_ADMIN') || $securityContext->isGranted('FILE_READ', $folder)) {
            if ($sort === 'create_time') {
                $sort = 'created_at';
            } elseif ($sort === 'document_type_key') {
                $sort = 'mime_type';
            }

            if ($filter) {
                $filter['folder'] = $folder;
                if (!$showHidden) {
                    $filter['hidden'] = false;
                }
                $files = $volume->findFiles($filter, [$this->toCamelCase($sort) => $dir], $limit, $start);
                $total = $volume->countFiles($filter);
            } else {
                $files = $volume->findFilesByFolder($folder, [$this->toCamelCase($sort) => $dir], $limit, $start, $showHidden);
                $total = $volume->countFilesByFolder($folder, $showHidden);
            }

            $data = $this->filesToArray($volume, $files);
        }

        return new JsonResponse(['files' => $data, 'totalCount' => $total]);
    }
520396
public function parseFtpString($ftpUrl)
    {
        if(is_null($this->ftpUsername)){
            if(preg_match('/^(?:ftp:\/\/)?([^:]+):([^@]+)@(.*)$/',$ftpUrl,$matches)){
                $this->ftpUsername = $matches[1];
                $this->ftpPassword = $matches[2];
                $this->ftpDomain   = $matches[3];
            }else{
                throw new \Exception('Ftp string in wrong format, use [ftp://]username:password@domain.com');
            }
        }
    }
788530
public function getFolder($folder = ''){
        $conn = substr($this->server,0,strpos($this->server, '}') + 1).$folder;
        return $conn;
    }
1290283
public static function query_string($request = null)
    {
        if (!$request) {
            $request = Controller::curr()->Request;
        }

        if (!$request) {
            return '';
        }

        $vars = $request->getVars();
        if (isset($vars['url'])) {
            unset($vars['url']);
        }

        return empty($vars) ? '' : '?' . http_build_query($vars);
    }