TYPO3 API  SVNRelease
class.livesearch.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2009-2011 Michael Klapper <michael.klapper@aoemedia.de>
00006  *  (c) 2010-2011 Jeff Segars <jeff@webempoweredchurch.org>
00007  *  All rights reserved
00008  *
00009  *  This script is part of the TYPO3 project. The TYPO3 project is
00010  *  free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  The GNU General Public License can be found at
00016  *  http://www.gnu.org/copyleft/gpl.html.
00017  *  A copy is found in the textfile GPL.txt and important notices to the license
00018  *  from the author is found in LICENSE.txt distributed with these scripts.
00019  *
00020  *
00021  *  This script is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  This copyright notice MUST APPEAR in all copies of the script!
00027  ***************************************************************/
00028 
00029 /**
00030  * Adds backend live search. to the toolbar
00031  *
00032  * @author Michael Klapper <michael.klapper@aoemedia.de>
00033  * @author Jeff Segars <jeff@webempoweredchurch.org>
00034  * @package TYPO3
00035  * @subpackage t3lib
00036  */
00037 class LiveSearch implements backend_toolbarItem {
00038 
00039     /**
00040      * reference back to the backend object
00041      *
00042      * @var TYPO3backend
00043      */
00044     protected $backendReference;
00045 
00046     /**
00047      * constructor
00048      *
00049      * @param   TYPO3backend    TYPO3 backend object reference
00050      */
00051     public function __construct(TYPO3backend &$backendReference = null) {
00052         $this->backendReference = $backendReference;
00053     }
00054 
00055     /**
00056      * checks whether the user has access to this toolbar item
00057      *
00058      * @return  boolean  true if user has access, false if not
00059      */
00060     public function checkAccess() {
00061         $access = FALSE;
00062 
00063             // Loads the backend modules available for the logged in user.
00064         $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00065         $loadModules->observeWorkspaces = TRUE;
00066         $loadModules->load($GLOBALS['TBE_MODULES']);
00067 
00068             // Live search is heavily dependent on the list module and only available when that module is.
00069         if (is_array($loadModules->modules['web']['sub']['list'])) {
00070             $access = TRUE;
00071         }
00072 
00073         return $access;
00074     }
00075 
00076     /**
00077      * Creates the selector for workspaces
00078      *
00079      * @return  string      workspace selector as HTML select
00080      */
00081     public function render() {
00082         $this->addJavascriptToBackend();
00083         return '<div class="live-search-wrapper">
00084                     <span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:search') .'" class="t3-icon t3-icon-apps t3-icon-apps-toolbar t3-icon-toolbar-menu-search">&nbsp;</span>
00085                     <input id="live-search-box" />
00086                 </div>';
00087     }
00088 
00089     /**
00090      * adds the necessary JavaScript to the backend
00091      *
00092      * @return  void
00093      */
00094     protected function addJavascriptToBackend() {
00095         $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
00096 
00097         $this->backendReference->addJavascriptFile('js/livesearch.js');
00098     }
00099 
00100     /**
00101      * returns additional attributes for the list item in the toolbar
00102      *
00103      * @return  string      list item HTML attibutes
00104      */
00105     public function getAdditionalAttributes() {
00106         return ' id="live-search-menu"';
00107     }
00108 
00109 }
00110 
00111 ?>