|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2008-2011 Steffen Kamper <info@sk-typo3.de> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 // load the language file 00029 $GLOBALS['LANG']->includeLLFile('EXT:sys_action/locallang.xml'); 00030 00031 /** 00032 * Adds action links to the backend's toolbar 00033 * 00034 * @author Steffen Kamper <info@sk-typo3.de> 00035 * @package TYPO3 00036 * @subpackage tx_sysaction 00037 */ 00038 class tx_sysactionToolbarMenu implements backend_toolbarItem { 00039 00040 /** 00041 * reference back to the backend object 00042 * 00043 * @var TYPO3backend 00044 */ 00045 protected $backendReference; 00046 protected $EXTKEY = 'sys_action'; 00047 00048 /** 00049 * constructor 00050 * 00051 * @return void 00052 */ 00053 public function __construct(TYPO3backend &$backendReference = null) { 00054 $this->backendReference = $backendReference; 00055 } 00056 00057 /** 00058 * sets the backend reference 00059 * 00060 * @param TYPO3backend backend object reference 00061 * @return void 00062 */ 00063 public function setBackend(TYPO3backend &$backendReference) { 00064 $this->backendReference = $backendReference; 00065 } 00066 00067 /** 00068 * renders the toolbar menu 00069 * 00070 * @return string the rendered backend menu 00071 * @author Ingo Renner <ingo@typo3.org> 00072 */ 00073 public function render() { 00074 $actionMenu = array(); 00075 $actionEntries = $this->getActionEntries(); 00076 00077 if ($actionEntries) { 00078 $this->addJavascriptToBackend(); 00079 $this->addCssToBackend(); 00080 $title = $GLOBALS['LANG']->getLL('action_toolbaritem', TRUE); 00081 00082 $actionMenu[] = '<a href="#" class="toolbar-item">'. 00083 t3lib_iconWorks::getSpriteIcon('apps-toolbar-menu-actions', array('title' => $title)) . 00084 '</a>'; 00085 00086 $actionMenu[] = '<ul class="toolbar-item-menu" style="display: none;">'; 00087 foreach ($actionEntries as $linkConf) { 00088 $actionMenu[] = '<li><a href="' . htmlspecialchars($linkConf[1]) . 00089 '" target="content">' . $linkConf[2] . 00090 htmlspecialchars($linkConf[0]) . '</a></li>'; 00091 } 00092 00093 $actionMenu[] = '</ul>'; 00094 return implode("\n", $actionMenu); 00095 } else { 00096 return ''; 00097 } 00098 00099 00100 } 00101 00102 /** 00103 * gets the entries for the action menu 00104 * 00105 * @return array array of action menu entries 00106 * @author Steffen Kamper <info@sk-typo3.de> 00107 * @author Ingo Renner <ingo@typo3.org> 00108 */ 00109 protected function getActionEntries() { 00110 $actions = array(); 00111 00112 if ($GLOBALS['BE_USER']->isAdmin()) { 00113 $queryResource = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 00114 '*', 00115 'sys_action', 00116 'pid = 0 AND hidden=0', 00117 '', 00118 'sys_action.sorting' 00119 ); 00120 } else { 00121 $groupList = 0; 00122 if ($GLOBALS['BE_USER']->groupList) { 00123 $groupList = $GLOBALS['BE_USER']->groupList; 00124 } 00125 00126 $queryResource = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( 00127 'sys_action.*', 00128 'sys_action', 00129 'sys_action_asgr_mm', 00130 'be_groups', 00131 ' AND be_groups.uid IN (' . $groupList . 00132 ') AND sys_action.pid = 0 AND sys_action.hidden = 0', 00133 'sys_action.uid', 00134 'sys_action.sorting' 00135 ); 00136 } 00137 00138 if ($queryResource) { 00139 while ($actionRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResource)) { 00140 $actions[] = array( 00141 $actionRow['title'], 00142 'mod.php?M=user_task&SET[function]==sys_action.tx_sysaction_task&show=' . $actionRow['uid'], 00143 t3lib_iconworks::getSpriteIconForRecord( 00144 'sys_action', 00145 $actionRow 00146 ), 00147 ); 00148 } 00149 00150 $GLOBALS['TYPO3_DB']->sql_free_result($queryResource); 00151 } 00152 00153 return $actions; 00154 } 00155 00156 /** 00157 * returns additional attributes for the list item in the toolbar 00158 * 00159 * @return string list item HTML attibutes 00160 */ 00161 public function getAdditionalAttributes() { 00162 return ' id="tx-sys-action-menu"'; 00163 } 00164 00165 /** 00166 * adds the neccessary javascript ot the backend 00167 * 00168 * @return void 00169 */ 00170 protected function addJavascriptToBackend() { 00171 $this->backendReference->addJavascriptFile( 00172 t3lib_extMgm::extRelPath($this->EXTKEY) . 'toolbarmenu/tx_sysactions.js' 00173 ); 00174 } 00175 00176 /** 00177 * adds the neccessary css ot the backend 00178 * 00179 * @return void 00180 */ 00181 protected function addCssToBackend() { 00182 $this->backendReference->addCssFile( 00183 'sysaction', 00184 t3lib_extMgm::extRelPath($this->EXTKEY) . 00185 'toolbarmenu/tx_sysactions.css' 00186 ); 00187 } 00188 00189 /** 00190 * Checks if user has access to the sys action menu 00191 * 00192 * @return boolean true if the user has access, false otherwise 00193 */ 00194 public function checkAccess() { 00195 // taskcenter is enabled for everybody 00196 return TRUE; 00197 } 00198 } 00199 00200 00201 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/sys_action/toolbarmenu/class.tx_sysaction_toolbarmenu.php'])) { 00202 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/sys_action/toolbarmenu/class.tx_sysaction_toolbarmenu.php']); 00203 } 00204 00205 ?>
1.8.0