TYPO3 CMS  TYPO3_6-2
QueryParser.php
Go to the documentation of this file.
1 <?php
3 
22 class QueryParser {
23 
27  protected $commandKey = '';
28 
32  protected $tableName = '';
33 
37  const COMMAND_KEY_INDICATOR = '#';
48  protected function extractKeyFromQuery($query) {
49  $keyAndValue = substr($query, 1);
50  $key = explode(':', $keyAndValue);
51  $this->commandKey = $key[0];
52  }
53 
60  public function getSearchQueryValue($query) {
61  $this->extractKeyFromQuery($query);
62  return str_replace(self::COMMAND_KEY_INDICATOR . $this->commandKey . self::COMMAND_SPLIT_INDICATOR, '', $query);
63  }
64 
71  public function getTableNameFromCommand($query) {
72  $tableName = '';
73  $this->extractKeyFromQuery($query);
74  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']) && array_key_exists($this->commandKey, $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'])) {
75  $tableName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'][$this->commandKey];
76  }
77  return $tableName;
78  }
79 
86  public function getId($query) {
87  return str_replace(self::COMMAND_KEY_INDICATOR, '', $query);
88  }
89 
96  public function isValidPageJump($query) {
97  $isValid = FALSE;
98  if (preg_match('~^#(\\d)+$~', $query)) {
99  $isValid = TRUE;
100  }
101  return $isValid;
102  }
103 
110  public function isValidCommand($query) {
111  $isValid = FALSE;
112  if (strpos($query, self::COMMAND_KEY_INDICATOR) === 0 && strpos($query, self::COMMAND_SPLIT_INDICATOR) > 1 && $this->getTableNameFromCommand($query)) {
113  $isValid = TRUE;
114  }
115  return $isValid;
116  }
117 
124  public function getCommandForTable($tableName) {
125  $commandArray = array_keys($GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'], $tableName);
126  if (is_array($commandArray)) {
127  $command = $commandArray[0];
128  } else {
129  $command = FALSE;
130  }
131  return $command;
132  }
133 
140  public function getCommandForPageJump($query) {
141  if ($this->isValidPageJump($query)) {
142  $command = $this->getCommandForTable('pages');
143  $id = $this->getId($query);
144  $resultQuery = self::COMMAND_KEY_INDICATOR . $command . self::COMMAND_SPLIT_INDICATOR . $id;
145  } else {
146  $resultQuery = FALSE;
147  }
148  return $resultQuery;
149  }
150 
151 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]