16432.diff

Administrator Admin, 2010-11-17 06:44

Download (48.1 KB)

View differences:

t3lib/config_default.php (working copy)
393 393
			)
394 394
		),
395 395
		'ExtDirect' => array(	// array of key value pairs (provider -> location:className) that holds the classes for the ExtDirect functionality
396
			'TYPO3.CSH.ExtDirect' => 't3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php:extDirect_DataProvider_ContextHelp'
396
			'TYPO3.CSH.ExtDirect' => 't3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php:extDirect_DataProvider_ContextHelp',
397
			'TYPO3.LiveSearchActions.ExtDirect' => 't3lib/extjs/dataprovider/class.extdirect_dataprovider_backendlivesearch.php:extDirect_DataProvider_BackendLiveSearch'
397 398
		),
398 399
	),
399 400
	'EXTCONF' => array(		// Here you may add manually set configuration options for your extensions. Eg. $TYPO3_CONF_VARS['EXTCONF']['my_extension_key']['my_option'] = 'my_value';
t3lib/search/class.t3lib_search_livesearch.php (revision 0)
1
<?php
2
/***************************************************************
3
 *  Copyright notice
4
 *
5
 *  (c) 2009-2010 Michael Klapper <michael.klapper@aoemedia.de>
6
 *  (c) 2010 Jeff Segars <jeff@webempoweredchurch.org>
7
 *  All rights reserved
8
 *
9
 *  This script is part of the TYPO3 project. The TYPO3 project is
10
 *  free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  (at your option) any later version.
14
 *
15
 *  The GNU General Public License can be found at
16
 *  http://www.gnu.org/copyleft/gpl.html.
17
 *  A copy is found in the textfile GPL.txt and important notices to the license
18
 *  from the author is found in LICENSE.txt distributed with these scripts.
19
 *
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28

  
29
/**
30
 * Class for handling backend live search.
31
 *
32
 * @author Michael Klapper <michael.klapper@aoemedia.de>
33
 * @author Jeff Segars <jeff@webempoweredchurch.org>
34
 * @package TYPO3
35
 * @subpackage t3lib
36
 */
37
class t3lib_search_livesearch {
38

  
39
	/**
40
	 * @var string
41
	 */
42
	const PAGE_JUMP_TABLE = 'pages';
43

  
44
	/**
45
	 * @var integer
46
	 */
47
	const RECURSIVE_PAGE_LEVEL = 99;
48

  
49
	/**
50
	 * @var integer
51
	 */
52
	const GROUP_TITLE_MAX_LENGTH = 15;
53

  
54
	/**
55
	 * @var integer
56
	 */
57
	const RECORD_TITLE_MAX_LENGTH = 37;
58

  
59
	/**
60
	 * @var string
61
	 */
62
	private $queryString = '';
63

  
64
	/**
65
	 * @var integer
66
	 */
67
	private $startCount = 0;
68

  
69
	/**
70
	 * @var integer
71
	 */
72
	private $limitCount = 5;
73

  
74
	/**
75
	 * @var string
76
	 */
77
	protected $userPermissions = '';
78

  
79
	/**
80
	 * @var t3lib_search_livesearch_queryParser
81
	 */
82
	protected $queryParser = null;
83

  
84
	/**
85
	 * Initialize access settings.
86
	 *
87
	 * @return void
88
	 */
89
	public function __construct() {
90
		$this->userPermissions = $GLOBALS['BE_USER']->getPagePermsClause(1);
91
		$this->queryParser = t3lib_div::makeInstance('t3lib_search_livesearch_queryParser');
92
	}
93

  
94
	/**
95
	 * Find records from database based on the given $searchQuery.
96
	 *
97
	 * @param string $searchQuery
98
	 * @return string Edit link to an page record if exists. Otherwise an empty string will returned
99
	 */
100
	public function findPage($searchQuery) {
101
		$link = '';
102
		$pageId = $this->queryParser->getId($searchQuery);
103
		$pageRecord = $this->findPageById($pageId);
104

  
105
		if (!empty($pageRecord)) {
106
			$link = $this->getEditLink(self::PAGE_JUMP_TABLE, $this->findPageById($pageId));
107
		}
108

  
109
		return $link;
110
	}
111

  
112
	/**
113
	 * Find records from database based on the given $searchQuery.
114
	 *
115
	 * @param string $searchQuery
116
	 * @return array Result list of database search.
117
	 */
118
	public function find($searchQuery) {
119
		$recordArray = array();
120
		$pageIdList = $this->getAvailablePageIds (
121
			implode(',', $GLOBALS['BE_USER']->returnWebmounts()),
122
			self::RECURSIVE_PAGE_LEVEL
123
		);
124
		$limit = $this->startCount . ',' . $this->limitCount;
125

  
126
		if ($this->queryParser->isValidCommand($searchQuery)) {
127
			$this->setQueryString($this->queryParser->getSearchQueryValue($searchQuery));
128
			$tableName = $this->queryParser->getTableNameFromCommand($searchQuery);
129
			try {
130
				$recordArray[] = $this->findByTable($tableName, $pageIdList, $limit);
131
			} catch (Exception $e) {
132
				// @todo Can we at least log this exception somewhere?
133
			}
134
		} else {
135
			$this->setQueryString($searchQuery);
136
			$recordArray = $this->findByGlobalTableList($pageIdList, $limit);
137
		}
138

  
139
		// @todo Need to make sure we don't return too many records.
140
		$recordArray = array_slice($recordArray, 0, 4);
141

  
142
		return $recordArray;
143
	}
144

  
145
	/**
146
	 * Retrieve the page record from given $id.
147
	 *
148
	 * @param integer $id
149
	 * @return array
150
	 */
151
	protected function findPageById($id) {
152
		$pageRecord = array();
153
		$row = t3lib_BEfunc::getRecord(self::PAGE_JUMP_TABLE, $id);
154

  
155
		if (is_array($row)) {
156
			$pageRecord = $row;
157
		}
158

  
159
		return $pageRecord;
160
	}
161

  
162
	/**
163
	 * Find records from all registered TCA table & column values.
164
	 *
165
	 * @param string $pageIdList Comma seperated list of page IDs
166
	 * @param string $limit MySql Limit notation
167
	 * @return array Records found in the database matching the searchQuery
168
	 */
169
	protected function findByGlobalTableList($pageIdList, $limit) {
170
		$getRecordArray = array();
171
		foreach ($GLOBALS['TCA'] as $tableName => $value) {
172
			try {
173
				$getRecordArray[] = $this->findByTable($tableName, $pageIdList, $limit);
174
			} catch (Exception $e) {
175
				// nothing found for table
176
				// @todo Need to at least log the exception or something.
177
			}
178
		}
179

  
180
		return $getRecordArray;
181
	}
182

  
183
	/**
184
	 * Find records by given table name.
185
	 *
186
	 * @param string $tableName Database table name
187
	 * @param string $pageIdList Comma seperated list of page IDs
188
	 * @param string $limit MySql Limit notation
189
	 * @return array Records found in the database matching the searchQuery
190
	 *
191
	 * @see getRecordArray()
192
	 * @see makeOrderByTable()
193
	 * @see makeQuerySearchByTable()
194
	 * @see extractSearchableFieldsFromTable()
195
	 */
196
	protected function findByTable($tableName, $pageIdList, $limit) {
197
		$getRecordArray = array();
198
		$fieldsToSearchWithin = $this->extractSearchableFieldsFromTable($tableName);
199
		$pageBasedPermission = ($tableName == 'pages' && $this->userPermissions) ? $this->userPermissions : '1=1 ' ;
200
		$where = 'pid IN(' . $pageIdList . ')' . $pageBasedPermission . $this->makeQuerySearchByTable($tableName, $fieldsToSearchWithin);
201
		$orderBy = $this->makeOrderByTable($tableName);
202
		try {
203
			$getRecordArray = $this->getRecordArray(
204
				$tableName,
205
				$pageBasedPermission . $this->makeQuerySearchByTable($tableName, $fieldsToSearchWithin),
206
				$this->makeOrderByTable($tableName),
207
				$limit
208
			);
209
		} catch (Exception $e) {
210
		}
211

  
212
		return $getRecordArray;
213
	}
214

  
215
	/**
216
	 * Proccess the Database operation to get the search result.
217
	 *
218
	 * @param string $tableName Database table name
219
	 * @param string $where
220
	 * @param string $orderBy
221
	 * @param string $limit MySql Limit notation
222
	 * @return array
223
	 *
224
	 * @see t3lib_db::exec_SELECT_queryArray()
225
	 * @see t3lib_db::sql_num_rows()
226
	 * @see t3lib_db::sql_fetch_assoc()
227
	 * @see t3lib_iconWorks::getSpriteIconForRecord()
228
	 * @see getTitleFromCurrentRow()
229
	 * @see getEditLink()
230
	 */
231
	protected function getRecordArray($tableName, $where, $orderBy, $limit) {
232
		$collect = array();
233
		$isFirst = true;
234
		$queryParts = array(
235
			'SELECT'  => '*',
236
			'FROM'	  => $tableName,
237
			'WHERE'	  => $where,
238
			'ORDERBY' => $orderBy,
239
			'LIMIT'	  => $limit
240
		);
241
		$result	 = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
242
		$dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
243

  
244
		if ($dbCount == 0) {
245
			// @todo Should we be throwing an exception here?
246
			// throw new Exception('Nothing found for table: '. $tableName);
247
		}
248

  
249
		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
250
			$collect[] = array (
251
				'id' => $tableName . ':' . $row['uid'],
252
				'recordTitle' => ($isFirst) ? $this->getRecordTitlePrep($this->getTitleOfCurrentRecordType($tableName), self::GROUP_TITLE_MAX_LENGTH) : '',
253
				'iconHTML' => t3lib_iconWorks::getSpriteIconForRecord($tableName, $row),
254
				'title' => $this->getRecordTitlePrep($this->getTitleFromCurrentRow($tableName, $row), self::RECORD_TITLE_MAX_LENGTH),
255
				'editLink' => $this->getEditLink($tableName, $row),
256
			);
257
			$isFirst = false;
258
		}
259

  
260
		return $collect;
261
	}
262

  
263
	/**
264
	 * Build a backend edit link based on given record.
265
	 *
266
	 * @param string $tableName Record table name
267
	 * @param array	 $row  Current record row from database.
268
	 * @return string Link to open an edit window for record.
269
	 *
270
	 * @see t3lib_BEfunc::readPageAccess()
271
	 */
272
	protected function getEditLink($tableName, $row) {
273
		$pageInfo = t3lib_BEfunc::readPageAccess($row['pid'], $this->userPermissions);
274
		$calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
275
		$editLink = '';
276

  
277
		if ($tableName == 'pages') {
278
			$localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
279
			$permsEdit = $localCalcPerms&2;
280
		} else {
281
			$permsEdit = $calcPerms&16;
282
		}
283

  
284
			// "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
285
			// @todo Is there an existing function to generate this link?
286
		if ($permsEdit) {
287
			$editLink = 'alt_doc.php?' . '&edit['.$tableName.']['.$row['uid'].']=edit';
288
		}
289

  
290
		return $editLink;
291
	}
292

  
293
	/**
294
	 * Retrieve the record name
295
	 *
296
	 * @param string $tableName Record table name
297
	 * @return string
298
	 */
299
	protected function getTitleOfCurrentRecordType($tableName) {
300
		return $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']);
301
	}
302

  
303
	/**
304
	 * Crops a title string to a limited lenght and if it really was cropped, wrap it in a <span title="...">|</span>,
305
	 * which offers a tooltip with the original title when moving mouse over it.
306
	 *
307
	 * @param	string		$title: The title string to be cropped
308
	 * @param	integer		$titleLength: Crop title after this length - if not set, BE_USER->uc['titleLen'] is used
309
	 * @return	string		The processed title string, wrapped in <span title="...">|</span> if cropped
310
	 */
311
	public function getRecordTitlePrep($title, $titleLength = 0) {
312
			// If $titleLength is not a valid positive integer, use BE_USER->uc['titleLen']:
313
		if (!$titleLength || !t3lib_div::testInt($titleLength) || $titleLength < 0) {
314
			$titleLength = $GLOBALS['BE_USER']->uc['titleLen'];
315
		}
316

  
317
		return htmlspecialchars(t3lib_div::fixed_lgd_cs($title, $titleLength));;
318
	}
319

  
320
	/**
321
	 * Retrieve the column name which contains the title value
322
	 *
323
	 * @param string $tableName Record table name
324
	 * @param array $row Current record row from database.
325
	 * @return string
326
	 *
327
	 * @todo Use the backend function to get the calculated label instead.
328
	 */
329
	protected function getTitleFromCurrentRow($tableName, $row) {
330
		$titleColumnName = $GLOBALS['TCA'][$tableName]['ctrl']['label'];
331
		return $row[$titleColumnName];
332
	}
333

  
334
	/**
335
	 * Build the MySql where clause by table.
336
	 *
337
	 * @param string $tableName Record table name
338
	 * @param array $fieldsToSearchWithin User right based visible fields where we can search within.
339
	 * @return string
340
	 */
341
	protected function makeQuerySearchByTable($tableName, $fieldsToSearchWithin) {
342
			// free text search
343
		$queryLikeStatement = ' LIKE \'%' . $this->getQueryString() . '%\'';
344
		$queryPart			= ' AND (' . implode($queryLikeStatement . ' OR ', $fieldsToSearchWithin) . $queryLikeStatement . ')';
345
		$queryPart		   .= t3lib_BEfunc::deleteClause($tableName);
346
		$queryPart		   .= t3lib_BEfunc::versioningPlaceholderClause($tableName);
347

  
348
		return $queryPart;
349
	}
350

  
351
	/**
352
	 * Build the MySql ORDER BY statement.
353
	 *
354
	 *
355
	 * @param string $tableName Record table name
356
	 * @return string
357
	 * @see t3lib_db::stripOrderBy()
358
	 */
359
	protected function makeOrderByTable($tableName) {
360
		$orderBy = '';
361

  
362
		if (is_array($GLOBALS['TCA'][$tableName]['ctrl']) && array_key_exists('sortby', $GLOBALS['TCA'][$tableName]['ctrl'])) {
363
			$orderBy = 'ORDER BY '.$GLOBALS['TCA'][$tableName]['ctrl']['sortby'];
364
		} else {
365
			$orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'];
366
		}
367

  
368
		return $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy);
369
	}
370

  
371
	/**
372
	 * Get all fields from given table where we can search for.
373
	 *
374
	 * @param string $tableName
375
	 * @return array
376
	 */
377
	protected function extractSearchableFieldsFromTable($tableName) {
378
		$fieldListArray = array();
379

  
380
			// Traverse configured columns and add them to field array, if available for user.
381
		foreach((array) $GLOBALS['TCA'][$tableName]['columns'] as $fieldName => $fieldValue) {
382
			// @todo Reformat
383
			if (
384
					(!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $tableName . ':' . $fieldName)) // does current user have access to the field
385
				&&
386
					($fieldValue['config']['type'] != 'passthrough') // field type is not searchable
387
				&&
388
					(!preg_match('/date|time|int/', $fieldValue['config']['eval'])) // field can't be of type date, time, int
389
				&&
390
					(
391
							($fieldValue['config']['type'] == 'text')
392
						||
393
							($fieldValue['config']['type'] == 'input')
394
					)
395
				) {
396
				$fieldListArray[] = $fieldName;
397
			}
398
		}
399

  
400
			// Add special fields:
401
		if ($GLOBALS['BE_USER']->isAdmin())	{
402
			$fieldListArray[] = 'uid';
403
			$fieldListArray[] = 'pid';
404
		}
405

  
406
		return $fieldListArray;
407
	}
408

  
409
	/**
410
	 * Safely retrieve the queryString.
411
	 *
412
	 * @return string
413
	 * @see t3lib_db::quoteStr()
414
	 */
415
	public function getQueryString() {
416
		return $GLOBALS['TYPO3_DB']->quoteStr($this->queryString, '');
417
	}
418

  
419
	/**
420
	 * Setter for limit value.
421
	 *
422
	 * @param integer $limitCount
423
	 * @return void
424
	 */
425
	public function setLimitCount($limitCount) {
426
		$limit = t3lib_div::intval_positive($limitCount);
427
		if ($limit > 0) {
428
			$this->limitCount = $limit;
429
		}
430
	}
431

  
432
	/**
433
	 * Setter for start count value.
434
	 *
435
	 * @param integer $startCount
436
	 * @return void
437
	 */
438
	public function setStartCount($startCount) {
439
		$this->startCount = t3lib_div::intval_positive($startCount);
440
	}
441

  
442
	/**
443
	 * Setter for the search query string.
444
	 *
445
	 * @param string $queryString
446
	 * @return void
447
	 * @see t3lib_div::removeXSS()
448
	 */
449
	public function setQueryString($queryString) {
450
		$this->queryString = t3lib_div::removeXSS($queryString);
451
	}
452

  
453
	/**
454
	 * Creates an instance of t3lib_pageTree which will select a page tree to
455
	 * $depth and return the object. In that object we will find the ids of the tree.
456
	 *
457
	 * @param	integer		Page id.
458
	 * @param	integer		Depth to go down.
459
	 *
460
	 * @return	string		coma separated list of uids
461
	 */
462
	protected function getAvailablePageIds($id, $depth) {
463
		$idList = '';
464
		$tree = t3lib_div::makeInstance('t3lib_pageTree');
465
		$tree->init('AND ' . $this->userPermissions);
466
		$tree->makeHTML = 0;
467
		$tree->fieldArray = Array('uid','php_tree_stop');
468
		if ($depth) {
469
			$tree->getTree($id, $depth, '');
470
		}
471
		$tree->ids[] = $id;
472
		$idList = implode(',', $tree->ids);
473
		return $idList;
474
	}
475
}
476

  
477
?>
t3lib/search/class.t3lib_search_livesearch_queryParser.php (revision 0)
1
<?php
2
/***************************************************************
3
 *  Copyright notice
4
 *
5
 *  (c) 2009-2010 Michael Klapper <michael.klapper@aoemedia.de>
6
 *  (c) 2010 Jeff Segars <jeff@webempoweredchurch.org>
7
 *  All rights reserved
8
 *
9
 *  This script is part of the TYPO3 project. The TYPO3 project is
10
 *  free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  (at your option) any later version.
14
 *
15
 *  The GNU General Public License can be found at
16
 *  http://www.gnu.org/copyleft/gpl.html.
17
 *  A copy is found in the textfile GPL.txt and important notices to the license
18
 *  from the author is found in LICENSE.txt distributed with these scripts.
19
 *
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28

  
29
/**
30
 * Class for parsing query parameters in backend live search.
31
 *
32
 * @author Michael Klapper <michael.klapper@aoemedia.de>
33
 * @author Jeff Segars <jeff@webempoweredchurch.org>
34
 * @package TYPO3
35
 * @subpackage t3lib
36
 */
37
class t3lib_search_livesearch_queryParser {
38

  
39
	/**
40
	 * @var string
41
	 */
42
	protected $commandKey = '';
43

  
44
	/**
45
	 * @var string
46
	 */
47
	protected $tableName  = '';
48

  
49
	/**
50
	 * @var string
51
	 */
52
	const COMMAND_KEY_INDICATOR = '#';
53

  
54
	/**
55
	 * @var string
56
	 */
57
	const COMMAND_SPLIT_INDICATOR = ':';
58

  
59
	/**
60
	 * Retrive the validated command key
61
	 *
62
	 * @return string Command name
63
	 */
64
	protected function extractKeyFromQuery($query) {
65
		$keyAndValue = substr($query, 1);
66
		$key = explode(':', $keyAndValue);
67
		$this->commandKey = $key[0];
68
	}
69

  
70
	/**
71
	 * Extract the search value from the full search query which contains also the command part.
72
	 *
73
	 * @param string $query For example #news:weather
74
	 * @return string The extracted search value
75
	 */
76
	public function getSearchQueryValue($query) {
77
		$this->extractKeyFromQuery($query);
78
		return str_replace(self::COMMAND_KEY_INDICATOR . $this->commandKey . self::COMMAND_SPLIT_INDICATOR, '', $query);
79
	}
80

  
81
	/**
82
	 * Find the registerd table command and retrieve the matching table name.
83
	 *
84
	 * @param string $query
85
	 * @return string Database Table name
86
	 */
87
	public function getTableNameFromCommand($query) {
88
		$tableName = '';
89
		$this->extractKeyFromQuery($query);
90
		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']) && array_key_exists($this->commandKey, $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'])) {
91
			$tableName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'][$this->commandKey];
92
		}
93
		return $tableName;
94
	}
95

  
96
	/**
97
	 * Verify if an given query contains a page jump command.
98
	 *
99
	 * @param string $query A valid value looks like '#14'
100
	 * @return integer
101
	 */
102
	public function getId($query) {
103
		return str_replace(self::COMMAND_KEY_INDICATOR, '', $query);
104
	}
105

  
106
	/**
107
	 * Verify if a given query contains a page jump command.
108
	 *
109
	 * @param string $query A valid value looks like '#14'
110
	 * @return boolean
111
	 */
112
	public function isValidPageJump($query) {
113
		$isValid = false;
114

  
115
		if (preg_match('~^#(\d)+$~', $query)) {
116
			$isValid = true;
117
		}
118

  
119
		return $isValid;
120
	}
121

  
122
	/**
123
	 * Verify if an given query contains an registered command key.
124
	 *
125
	 * @param string $query
126
	 * @return boolean
127
	 */
128
	public function isValidCommand($query) {
129
		$isValid = false;
130
		if (strpos($query, self::COMMAND_KEY_INDICATOR) === 0 && strpos($query, self::COMMAND_SPLIT_INDICATOR) > 1) {
131
			$isValid = true;
132
		}
133

  
134
		return $isValid;
135
	}
136
}
137
?>
t3lib/core_autoload.php (working copy)
58 58
	't3lib_registry' => PATH_t3lib . 'class.t3lib_registry.php',
59 59
	't3lib_rteapi' => PATH_t3lib . 'class.t3lib_rteapi.php',
60 60
	't3lib_scbase' => PATH_t3lib . 'class.t3lib_scbase.php',
61
	't3lib_search_livesearch' => PATH_t3lib . 'search/class.t3lib_search_livesearch.php',
62
	't3lib_search_livesearch_queryParser' => PATH_t3lib . 'search/class.t3lib_search_livesearch_queryParser.php',
61 63
	't3lib_softrefproc' => PATH_t3lib . 'class.t3lib_softrefproc.php',
62 64
	't3lib_sqlengine' => PATH_t3lib . 'class.t3lib_sqlengine.php',
63 65
	't3lib_sqlengine_resultobj' => PATH_t3lib . 'class.t3lib_sqlengine.php',
t3lib/extjs/dataprovider/class.extdirect_dataprovider_backendlivesearch.php (revision 0)
1
<?php
2
/***************************************************************
3
 *  Copyright notice
4
 *
5
 *  (c) 2009-2010 Michael Klapper <michael.klapper@aoemedia.de>
6
 *  (c) 2010 Jeff Segars <jeff@webempoweredchurch.org>
7
 *  All rights reserved
8
 *
9
 *  This script is part of the TYPO3 project. The TYPO3 project is
10
 *  free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  (at your option) any later version.
14
 *
15
 *  The GNU General Public License can be found at
16
 *  http://www.gnu.org/copyleft/gpl.html.
17
 *  A copy is found in the textfile GPL.txt and important notices to the license
18
 *  from the author is found in LICENSE.txt distributed with these scripts.
19
 *
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28

  
29
/**
30
 * ExtDirect Class for handling backend live search.
31
 *
32
 * @author Michael Klapper <michael.klapper@aoemedia.de>
33
 * @author Jeff Segars <jeff@webempoweredchurch.org>
34
 * @package TYPO3
35
 * @subpackage t3lib
36
 */
37
class extDirect_dataProvider_BackendLiveSearch {
38

  
39
	/**
40
	 * @var array
41
	 */
42
	protected $searchResults = array (
43
		'pageJump'	  => '',
44
		'searchItems' => array()
45
	);
46

  
47
	/**
48
	 * @var array
49
	 */
50
	protected $helpContent = array (
51
		'title' => 'How to use advanced search tags',
52
		'text'  => 'Search in certain tables:<br />page:Home will search for all pages with the title "Home"',
53
		'keys'	=> array(),
54
	);
55

  
56
	/**
57
	 * @var t3lib_search_livesearch
58
	 */
59
	protected $liveSearch = null;
60

  
61
	/**
62
	 * @var t3lib_search_livesearch_queryParser
63
	 */
64
	protected $queryParser = null;
65

  
66
	/**
67
	 * Initialize the live search
68
	 */
69
	public function __construct() {
70
		// @todo Use the autoloader for this. Not sure why its not working.
71
		require_once(PATH_t3lib . 'search/class.t3lib_search_livesearch_queryParser.php');
72

  
73
		$this->liveSearch  = t3lib_div::makeInstance('t3lib_search_livesearch');
74
		$this->queryParser = t3lib_div::makeInstance('t3lib_search_livesearch_queryParser');
75
	}
76

  
77
	/**
78
	 *
79
	 *
80
	 * @param stdClass $command
81
	 *
82
	 * @return array
83
	 */
84
	public function find($command) {
85
		$this->liveSearch->setStartCount($command->start);
86
		$this->liveSearch->setLimitCount($command->limit);
87
		$this->liveSearch->setQueryString($command->query);
88

  
89
			// jump & edit - find page and retrieve an edit link (this is only for pages
90
		if ($this->queryParser->isValidPageJump($command->query)) {
91
			$this->searchResults['pageJump'] = $this->liveSearch->findPage($command->query);
92

  
93
			// search through the database and find records who match to the given search string
94
		} else {
95
			$resultArray = $this->liveSearch->find($command->query);
96

  
97
			foreach ($resultArray as $resultFromTable) {
98
				foreach ($resultFromTable as $item) {
99
					$this->searchResults['searchItems'][] = $item;
100
				}
101
			}
102
		}
103

  
104
		return $this->searchResults;
105
	}
106

  
107
	/**
108
	 * Build up and retrieve the general and custom help text "How can you search"
109
	 *
110
	 * @return array
111
	 */
112
	public function getHelp() {
113
		$content = array();
114
		$this->helpContent['keys'] = $this->getRegisteredHelpContent();
115

  
116
		return $this->helpContent;
117
	}
118

  
119

  
120
	/**
121
	 * Find all registerd help information.
122
	 *
123
	 * @return array All registered help content will collected returned
124
	 * @todo Doesn't actually return any data
125
	 */
126
	public function getRegisteredHelpContent() {
127
		$helpArray = array();
128
		$liveSearchConfiguration = ((is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'])) ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'] : array());
129

  
130
		foreach ($liveSearchConfiguration as $key => $table) {
131
			$helpArray[] = '#' . $key;
132
		}
133

  
134
		return $helpArray;
135
	}
136

  
137
}
138
?>
typo3/js/livesearch.js (revision 0)
1
/***************************************************************
2
 *  Copyright notice
3
 *
4
 *  (c) 2009-2010 Michael Klapper <michael.klapper@aoemedia.de>
5
 *  (c) 2010 Jeff Segars <jeff@webempoweredchurch.org>
6
 *  All rights reserved
7
 *
8
 *  This script is part of the TYPO3 project. The TYPO3 project is
9
 *  free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  The GNU General Public License can be found at
15
 *  http://www.gnu.org/copyleft/gpl.html.
16
 *  A copy is found in the textfile GPL.txt and important notices to the license
17
 *  from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
Ext.namespace('TYPO3');
29

  
30
TYPO3.BackendLiveSearch = Ext.extend(Ext.form.ComboBox, {
31
	ctCls: 'live-search-results',
32
	listClass: 'live-search-list',
33
	dbListUrl : 'db_list.php?id=0&search_levels=4&search_field=',
34
	width: 205,
35
	listWidth: 315,
36
	minChars: 2,
37
	resizable: false,
38
	displayField: 'title',
39
	enableKeyEvents: true,
40
	dataProvider: null,
41
	title: null,
42
	helpTitle: null,
43
	emptyText: null,
44
	loadingText: null,
45
	listEmptyText: null,
46
	listAlign : 'tr-br',
47
	itemSelector: 'div.search-item-title',
48
	triggerClass : 'x-form-clear-trigger',
49
	triggerConfig: '<span tag="a" class="t3-icon t3-icon-actions t3-icon-actions-input t3-icon-input-clear t3-tceforms-input-clearer">&nbsp;</span>',
50
	onTriggerClick: function() {
51
		// Empty the form field, give it focus, and collapse the results
52
		this.reset(this);
53
		this.focus();
54
		this.collapse();
55
	},
56
	tpl: new Ext.XTemplate(
57
		'<table border="0" cellspacing="0">',
58
			'<tpl for=".">',
59
				'<tr class="search-item">',
60
					'<td class="search-item-type" width="105" align="right">{recordTitle}</td>',
61
					'<td class="search-item-content" width="195">',
62
						'<div class="search-item-title">{iconHTML} {title}</span>',
63
					'</td>',
64
				'</tr>',
65
			'</tpl>',
66
		'</table>'
67
	),
68

  
69
	dataReader : new Ext.data.JsonReader({
70
		idProperty : 'type',
71
		root : 'searchItems',
72
		fields : [
73
			{name: 'recordTitle'},
74
			{name: 'id'},
75
			{name: 'iconHTML'},		 
76
			{name: 'title'},
77
			{name: 'editLink'}
78
		]
79
	}),
80
	listeners: {
81
		select : {
82
			scope: this,
83
			fn: function (combo, record, index) {
84
				TYPO3.Backend.loadModule('web', 'web_layout', record.data.editLink);
85
			}
86
		},
87
		focus : {
88
			fn: function() {
89
				if (this.getValue() == this.emptyText) {
90
					this.reset(this);
91
				}
92
			}
93
		}
94
		/*
95
		specialkey : function () {
96
			console.log('specialkes', this, arguments);
97
			TYPO3.Backend.loadModule('web', 'web_list', this.dbListUrl);
98
		}
99
		*/
100
	},
101

  
102
	/**
103
	 * Initializes the component.
104
	 */
105
	initComponent: function() {
106
		this.store = new Ext.data.DirectStore({
107
			directFn: this.dataProvider.find,
108
			reader: this.dataReader
109
		});
110
		TYPO3.BackendLiveSearch.superclass.initComponent.apply(this, arguments);
111
	},
112

  
113
	restrictHeight : function(){
114
		this.innerList.dom.style.height = '';
115
		var inner = this.innerList.dom;
116
		var pad = this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight + 30; // @todo Remove hardcoded 30
117
		var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
118
		var ha = this.getPosition()[1]-Ext.getBody().getScroll().top;
119
		var hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height;
120
		var space = Math.max(ha, hb, this.minHeight || 0)-pad-2;
121
		/** BUG FIX **/
122
		if (this.shadow === true) { space-=this.list.shadow.offset; }
123

  
124
		h = Math.min(h, space, this.maxHeight);
125

  
126
		/**
127
		 * @internal The calcated height of "h" in the line before seems not working as expected.
128
		 *			 If i define a min height, the box shold at least use this height also if only one entry is in there 
129
		 */
130
		//h = this.maxHeight;
131

  
132
		this.innerList.setHeight(h);
133
		this.list.beginUpdate();
134
		this.list.setHeight(h+pad);
135
		this.list.alignTo(this.el, this.listAlign);
136
		this.list.endUpdate();
137
	},
138

  
139
	initList : function () {
140
		TYPO3.BackendLiveSearch.superclass.initList.apply(this, arguments);
141

  
142
		var cls = 'x-combo-list';
143

  
144
		/**
145
		 * Create bottom Toolbar to the result layer
146
		 */
147
		this.footer = this.list.createChild({cls:cls+'-ft'});
148

  
149
		this.pageTb = new Ext.Toolbar({
150
			renderTo:this.footer,
151
			height: 30,
152
			items: [{
153
				xtype: 'tbfill',
154
				autoWidth : true
155
			},{
156
				xtype: 'button',
157
				text: TYPO3.LLL.liveSearch.showAllResults,
158
				arrowAlign : 'right',
159
				shadow: false,
160
				icon : '../typo3/sysext/t3skin/icons/module_web_list.gif',
161
				listeners : {
162
					scope : this,
163
					click : function () {
164
							// go to db_list.php and search for given search value
165
							// @todo the current selected page ID from the page tree is required, also we need the
166
							// values of $BE_USER->returnWebmounts() to search only during the allowed pages
167
						TYPO3.Backend.loadModule('web', 'web_list', this.dbListUrl + this.getValue());
168
						this.collapse();
169
					}
170
				}
171
			}]
172
		});
173
		this.assetHeight += this.footer.getHeight();
174
	},
175

  
176
	// private
177
	onLoad : function(){
178
		TYPO3.BackendLiveSearch.superclass.onLoad.apply(this, arguments);
179

  
180
		// If an pageJump request is done this will immediately load the record for editing.
181
		if (this.dataReader.jsonData.pageJump != '') {
182
			this.collapse();
183
			TYPO3.Backend.loadModule('web', 'web_list', this.dataReader.jsonData.pageJump);
184
		} else {
185
			// Add an event handler to each iframe, closing the search window when there's a click inside the iframe
186
			// @todo Is there a cleaner way to handle this?
187
			var iframes = Ext.query('iframe');
188
			Ext.each(iframes, function(item, index, allItems) {
189
				item.contentWindow.document.body.onclick = function() {
190
					if (parent.TYPO3LiveSearch && parent.TYPO3LiveSearch.isExpanded()) {
191
						parent.TYPO3LiveSearch.collapse();
192
					}
193
				};
194
			}, this);
195
		}
196
	},
197

  
198
	initQuery : function(){
199
		TYPO3.BackendLiveSearch.superclass.initQuery.apply(this, arguments);
200
		this.removeHelp();
201
	},
202
	initHelp : function () {
203
		if(!this.helpList){
204
			var cls = 'search-list-help';
205

  
206
			this.helpList = new Ext.Layer({
207
				parentEl: this.getListParent(),
208
				shadow: this.shadow,
209
				cls: [cls, this.listClass].join(' '),
210
				constrain:false
211
			});
212

  
213
			var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
214
			this.helpList.setSize(lw);
215
			this.helpList.swallowEvent('mousewheel');
216
			if(this.syncFont !== false){
217
				this.helpList.setStyle('font-size', this.el.getStyle('font-size'));
218
			}
219

  
220
			this.innerHelpList = this.helpList.createChild({cls:cls+'-inner'});
221
			this.mon(this.innerHelpList, 'mouseover', this.onViewOver, this);
222
			this.mon(this.innerHelpList, 'mousemove', this.onViewMove, this);
223
			this.innerHelpList.setWidth(lw - this.helpList.getFrameWidth('lr'));
224

  
225
			if(!this.helpTpl){
226
				this.helpTpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
227
			 }
228

  
229
			/**
230
			* The {@link Ext.DataView DataView} used to display the ComboBox's options.
231
			* @type Ext.DataView
232
			*/
233
			this.helpView = new Ext.DataView({
234
				applyTo: this.innerHelpList,
235
				tpl: this.helpTpl,
236
				singleSelect: true,
237
				selectedClass: this.selectedClass,
238
				itemSelector: this.itemSelector || '.' + cls + '-item',
239
				emptyText: this.listEmptyText
240
			});
241

  
242
			this.helpList.createChild({
243
				cls: cls + '-content',
244
				html: '<strong>' + this.helpTitle + '</strong><p>' + TYPO3.LLL.liveSearch.helpDescription + '<br /> ' + TYPO3.LLL.liveSearch.helpDescriptionPages + '</p>'
245
			});
246

  
247
			this.helpList.alignTo(this.wrap, this.listAlign);
248
			this.helpList.show();
249

  
250
			var iframes = Ext.query('iframe');
251
			Ext.each(iframes, function(item, index, allItems) {
252
				item.contentWindow.document.body.onclick = function() {
253
					if (parent.TYPO3LiveSearch && parent.TYPO3LiveSearch.helpList.isVisible()) {
254
						parent.TYPO3LiveSearch.helpList.remove();
255
					}
256
				};
257
			}, this);
258

  
259
		}
260
	},
261
	removeHelp : function() {
262
		if (this.helpList) {
263
			this.helpList.destroy();
264
		}
265
	},
266
	onFocus : function() {
267
		TYPO3.BackendLiveSearch.superclass.onFocus.apply(this, arguments);
268

  
269
		// If search is blank, show the help on focus. Otherwise, show last results
270
		if (this.getValue() == '') {
271
			this.initHelp();
272
		} else {
273
			this.expand();
274
		}
275
	},
276
	postBlur : function() {
277
		TYPO3.BackendLiveSearch.superclass.postBlur.apply(this, arguments);
278
		this.removeHelp();
279
	},
280
	getTriggerWidth : function() {
281
		return 0;
282
	},
283
	reset : function() {
284
	    this.originalValue = this.emptyText;
285
		TYPO3.BackendLiveSearch.superclass.reset.apply(this, arguments);
286
	},
287
	onRender_old : function () {
288
		TYPO3.BackendLiveSearch.superclass.onRender.apply(this, arguments);
289
		this.on('focus', function () {
290
			if (this.getValue() == '') {
291
				this.initHelp();
292
			}
293
		}, this, {single: true});
294
	}
295
});
296

  
297
var TYPO3LiveSearch;
298

  
299
Ext.onReady(function() {
300
	TYPO3LiveSearch = new TYPO3.BackendLiveSearch({
301
		dataProvider: TYPO3.LiveSearchActions.ExtDirect,
302
		title: TYPO3.LLL.liveSearch.title,
303
		helpTitle: TYPO3.LLL.liveSearch.helpTitle,
304
		emptyText: TYPO3.LLL.liveSearch.emptyText,
305
		loadingText: TYPO3.LLL.liveSearch.loadingText,
306
		listEmptyText: TYPO3.LLL.liveSearch.listEmptyText
307
	});
308
	
309
	TYPO3LiveSearch.applyToMarkup(Ext.get('live-search-box'));
310
});
typo3/classes/class.livesearch.php (revision 0)
1
<?php
2
/***************************************************************
3
 *  Copyright notice
4
 *
5
 *  (c) 2009-2010 Michael Klapper <michael.klapper@aoemedia.de>
6
 *  (c) 2010 Jeff Segars <jeff@webempoweredchurch.org>
7
 *  All rights reserved
8
 *
9
 *  This script is part of the TYPO3 project. The TYPO3 project is
10
 *  free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  (at your option) any later version.
14
 *
15
 *  The GNU General Public License can be found at
16
 *  http://www.gnu.org/copyleft/gpl.html.
17
 *  A copy is found in the textfile GPL.txt and important notices to the license
18
 *  from the author is found in LICENSE.txt distributed with these scripts.
19
 *
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28

  
29
/**
30
 * Adds backend live search. to the toolbar
31
 *
32
 * @author Michael Klapper <michael.klapper@aoemedia.de>
33
 * @author Jeff Segars <jeff@webempoweredchurch.org>
34
 * @package TYPO3
35
 * @subpackage t3lib
36
 */
37
class LiveSearch implements backend_toolbarItem {
38

  
39
	/**
40
	 * reference back to the backend object
41
	 *
42
	 * @var	TYPO3backend
43
	 */
44
	protected $backendReference;
45

  
46
	/**
47
	 * constructor
48
	 *
49
	 * @param	TYPO3backend	TYPO3 backend object reference
50
	 */
51
	public function __construct(TYPO3backend &$backendReference = null) {
52
		$this->backendReference = $backendReference;
53
	}
54

  
55
	/**
56
	 * checks whether the user has access to this toolbar item
57
	 *
58
	 * @return  boolean  true if user has access, false if not
59
	 */
60
	public function checkAccess() {
61
			// LiveSearch module is enabled for everybody
62
		return true;
63
	}
64

  
65
	/**
66
	 * Creates the selector for workspaces
67
	 *
68
	 * @return	string		workspace selector as HTML select
69
	 */
70
	public function render() {
71
		$this->addJavascriptToBackend();
72
		return '<div class="live-search-wrapper">
73
					<span title="Search" class="t3-icon t3-icon-apps t3-icon-apps-toolbar t3-icon-toolbar-menu-search">&nbsp;</span>
74
					<input id="live-search-box" />
75
				</div>';
76
	}
77

  
78
	/**
79
	 * adds the necessary JavaScript to the backend
80
	 *
81
	 * @return	void
82
	 */
83
	protected function addJavascriptToBackend() {
84
		$pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
85
		$pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.LiveSearchActions', 'text/javascript', $compress = FALSE);
86

  
87
		$this->backendReference->addJavascriptFile('js/livesearch.js');
88
	}
89

  
90
	/**
91
	 * returns additional attributes for the list item in the toolbar
92
	 *
93
	 * @return	string		list item HTML attibutes
94
	 */
95
	public function getAdditionalAttributes() {
96
		return ' id="live-search-menu"';
97
	}
98

  
99
}
100

  
101
?>
typo3/classes/class.backendsearchmenu.php (working copy)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2007-2010 Ingo Renner <ingo@typo3.org>
6
*  All rights reserved
7
*
8
*  This script is part of the TYPO3 project. The TYPO3 project is
9
*  free software; you can redistribute it and/or modify
10
*  it under the terms of the GNU General Public License as published by
11
*  the Free Software Foundation; either version 2 of the License, or
12
*  (at your option) any later version.
13
*
14
*  The GNU General Public License can be found at
15
*  http://www.gnu.org/copyleft/gpl.html.
16
*  A copy is found in the textfile GPL.txt and important notices to the license
17
*  from the author is found in LICENSE.txt distributed with these scripts.
18
*
19
*
20
*  This script is distributed in the hope that it will be useful,
21
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
*  GNU General Public License for more details.
24
*
25
*  This copyright notice MUST APPEAR in all copies of the script!
26
***************************************************************/
27

  
28

  
29
/**
30
 * class to render the backend search toolbar item menu
31
 *
32
 * $Id$
33
 *
34
 * @author	Ingo Renner <ingo@typo3.org>
35
 * @package TYPO3
36
 * @subpackage core
37
 */
38
class BackendSearchMenu implements backend_toolbarItem {
39

  
40
	/**
41
	 * reference back to the backend object
42
	 *
43
	 * @var	TYPO3backend
44
	 */
45
	protected $backendReference;
46

  
47
	/**
48
	 * constructor
49
	 *
50
	 * @param	TYPO3backend	TYPO3 backend object reference
51
	 */
52
	public function __construct(TYPO3backend &$backendReference = null) {
53
		$this->backendReference = $backendReference;
54
	}
55

  
56
	/**
57
	 * checks whether the user has access to this toolbar item
58
	 *
59
	 * @return  boolean  true if user has access, false if not
60
	 */
61
	public function checkAccess() {
62
			// Backendsearch module is enabled for everybody
63
		return true;
64
	}
65

  
66
	/**
67
	 * Creates the selector for workspaces
68
	 *
69
	 * @return	string		workspace selector as HTML select
70
	 */
71
	public function render() {
72
		$title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:toolbarItems.search', true);
73
		$this->addJavascriptToBackend();
74
		$searchMenu = array();
75

  
76
		$searchMenu[] = '<a href="#" class="toolbar-item">' .
77
			t3lib_iconWorks::getSpriteIcon('apps-toolbar-menu-search', array('title' => $title)) .
78
			'</a>';
79

  
80
		$searchMenu[] = '<div class="toolbar-item-menu" style="display: none;">';
81
		$searchMenu[] = '<input type="text" id="search-query" name="search-query" value="" />';
82
		$searchMenu[] = '</div>';
83

  
84
		return implode(LF, $searchMenu);
85
	}
86

  
87
	/**
88
	 * adds the necessary JavaScript to the backend
89
	 *
90
	 * @return	void
91
	 */
92
	protected function addJavascriptToBackend() {
93
		$this->backendReference->addJavascriptFile('js/backendsearch.js');
94
	}
95

  
96
	/**
97
	 * returns additional attributes for the list item in the toolbar
98
	 *
99
	 * @return	string		list item HTML attibutes
100
	 */
101
	public function getAdditionalAttributes() {
102
		return ' id="backend-search-menu"';
103
	}
104

  
105
}
106

  
107

  
108
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.backendsearchmenu.php'])	{
109
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.backendsearchmenu.php']);
110
}
111

  
112
?>
typo3/backend.php (working copy)
36 36
	// core toolbar items
37 37
require('classes/class.clearcachemenu.php');
38 38
require('classes/class.shortcutmenu.php');
39
require('classes/class.backendsearchmenu.php');
39
require('classes/class.livesearch.php');
40 40

  
41 41
require_once('class.alt_menu_functions.inc');
42 42
$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml');
......
172 172
		$coreToolbarItems = array(
173 173
			'shortcuts'         => 'ShortcutMenu',
174 174
			'clearCacheActions' => 'ClearCacheMenu',
175
			'backendSearch'     => 'BackendSearchMenu'
175
			'liveSearch'        => 'LiveSearch'
176 176
		);
177 177

  
178 178
		foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
......
330 330
	protected function renderToolbar() {
331 331

  
332 332
			// move search to last position
333
		$search = $this->toolbarItems['backendSearch'];
334
		unset($this->toolbarItems['backendSearch']);
335
		$this->toolbarItems['backendSearch'] = $search;
333
		$search = $this->toolbarItems['liveSearch'];
334
		unset($this->toolbarItems['liveSearch']);
335
		$this->toolbarItems['liveSearch'] = $search;
336 336

  
337 337
		$toolbar = '<ul id="typo3-toolbar">';
338 338
		$toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
......
496 496
			'allError401' => $GLOBALS['LANG']->getLL('fileUpload_allError401'),
497 497
			'allError2038' => $GLOBALS['LANG']->getLL('fileUpload_allError2038'),
498 498
		);
499

  
499
		$t3LLLliveSearch = array(
500
			'title' => $GLOBALS['LANG']->getLL('liveSearch_title'),
501
			'helpTitle' => $GLOBALS['LANG']->getLL('liveSearch_helpTitle'),
502
			'emptyText' => $GLOBALS['LANG']->getLL('liveSearch_emptyText'),
503
			'loadingText' => $GLOBALS['LANG']->getLL('liveSearch_loadingText'),
504
			'listEmptyText' => $GLOBALS['LANG']->getLL('liveSearch_listEmptyText'),
505
			'showAllResults' => $GLOBALS['LANG']->getLL('liveSearch_showAllResults'),
506
			'helpDescription' => $GLOBALS['LANG']->getLL('liveSearch_helpDescription'),
507
			'helpDescriptionPages' => $GLOBALS['LANG']->getLL('liveSearch_helpDescriptionPages'),
508
			'helpDescriptionContent' => $GLOBALS['LANG']->getLL('liveSearch_helpDescriptionContent')
509
		);
500 510
			// Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
501 511
		if ($GLOBALS['LANG']->charSet !== 'utf-8') {
502 512
			$t3Configuration['username'] = $GLOBALS['LANG']->csConvObj->conv($t3Configuration['username'], $GLOBALS['LANG']->charSet, 'utf-8');
503 513
			$GLOBALS['LANG']->csConvObj->convArray($t3LLLcore, $GLOBALS['LANG']->charSet, 'utf-8');
504 514
			$GLOBALS['LANG']->csConvObj->convArray($t3LLLfileUpload, $GLOBALS['LANG']->charSet, 'utf-8');
515
			$GLOBALS['LANG']->csCOnfObj->convArray($t3LLLliveSearch, $GLOBALS['LANG']->charSet, 'utf-8');
505 516
		}
506 517

  
507 518
		$this->js .= '
508 519
	TYPO3.configuration = ' . json_encode($t3Configuration) . ';
509 520
	TYPO3.LLL = {
510 521
		core : ' . json_encode($t3LLLcore) . ',
511
		fileUpload: ' . json_encode($t3LLLfileUpload) . '
522
		fileUpload: ' . json_encode($t3LLLfileUpload) . ',
523
		liveSearch: ' . json_encode($t3LLLliveSearch) . '
512 524
	};
513 525

  
514 526
	/**
typo3/sysext/t3skin/stylesheets/visual/toolbar_livesearch.css (revision 0)
1
/* - - - - - - - - - - - - - - - - - - - - -
2
Backend  Live Search
3
- - - - - - - - - - - - - - - - - - - - - */
4

  
5
.live-search-results .t3-icon-toolbar-menu-search {
6
	position: absolute;
7
	z-index: 3000;
8
	top: 0;
9
	margin: 3px;
10
}
11

  
12
.t3-icon-input-clear {
13
	position: absolute;
14
	top: 0px;
15
	right: 20px;
16
}
17

  
18
#live-search-box {
19
	padding-left: 20px;
20
	width: 180px;
21
	border: none;
22
}
23

  
24
.live-search-list {
25
	background-color: white;
26
	border: none;
27
}
28

  
29
.live-search-list .x-combo-list {
30
	background-color: white;
31
}
32

  
33
.live-search-list .x-combo-list-inner {
34
	padding-bottom: 5px;
35
}
36

  
37
.live-search-list .x-combo-list-hd {
38
	background: none;
39
	border: none;
40
	margin-left: 110px;
41
	color: #ddd;
42
}
43

  
44
.search-list-help-content {
45
	margin: 5px;
46
	height: 100%;
47
	padding: 0.6em 0.6em 0.6em 2.6em;
48
	background-repeat: no-repeat;
49
	background-position: 0.5em 0.7em;
50
	border: 1px solid;
51
	color: #000000;
52

  
53
	background-color: #ddeef9;
54
	border-color: #8aafc4;
55
}
56

  
57
.live-search-list .search-item-type {
58
	border-right: 1px solid #ddd;
59
	padding: 2px 5px 2px 0;
60
}
61

  
62
.live-search-list .search-item-content {
63
	padding: 0 8px;
64
}
65

  
66
.live-search-list .search-item-content .search-item-title {
67
	padding: 2px;
68
	border: none !important;
69
}
typo3/sysext/lang/locallang_misc.xml (working copy)
132 132
			<label index="fileUpload_allErrorMessageText"><![CDATA[All of your uploads failed.<br /><br />If this problem persists, please try another browser, contact your administrator or disable this "Flash Uploader" in your User Settings.<br /><br />Detailed problem description:<br />]]></label>
133 133
			<label index="fileUpload_allError401">The server returned the status code 401, which is related to a .htaccess file used for password protection on your server. Unfortunately this can not be handled by your browser's Flash plugin.</label>
134 134
			<label index="fileUpload_allError2038">An input/output error occured (Error #2038). This i.e. happens with servers using a self-signed SSL certificate, which is a limitation of your browser's Flash plugin.</label>
135
			<label index="liveSearch_title">Short result list</label>
136
			<label index="liveSearch_emptyText">Enter search term</label>
137
			<label index="liveSearch_loadingText">Searching...</label>
138
			<label index="liveSearch_listEmptyText">No results found.</label>
139
			<label index="liveSearch_showAllResults">Show All</label>
140
			<label index="liveSearch_helpTitle">How to use advanced search tags</label>
141
			<label index="liveSearch_helpDescription">Search in certain tables:</label>
142
			<label index="liveSearch_helpDescriptionPages">#page:Home will search for all pages with the title "Home"</label>
135 143
		</languageKey>
136 144
	</data>
137 145
</T3locallang>
... This diff was truncated because it exceeds the maximum size that can be displayed.