TYPO3 API  SVNRelease
class.tx_impexp_clickmenu.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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  * Adding Import/Export clickmenu item
00029  *
00030  * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
00031  * XHTML compliant
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   67: class tx_impexp_clickmenu
00041  *   79:     function main(&$backRef,$menuItems,$table,$uid)
00042  *  121:     function includeLL()
00043  *
00044  * TOTAL FUNCTIONS: 2
00045  * (This index is automatically created/updated by the extension "extdeveval")
00046  *
00047  */
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 /**
00061  * Adding Import/Export clickmenu item
00062  *
00063  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00064  * @package TYPO3
00065  * @subpackage tx_impexp
00066  */
00067 class tx_impexp_clickmenu {
00068 
00069     /**
00070      * Processing of clickmenu items
00071      *
00072      * @param   object      Reference to parent
00073      * @param   array       Menu items array to modify
00074      * @param   string      Table name
00075      * @param   integer     Uid of the record
00076      * @return  array       Menu item array, returned after modification
00077      * @todo    Skinning for icons...
00078      */
00079     function main(&$backRef,$menuItems,$table,$uid) {
00080         global $BE_USER,$TCA;
00081 
00082         $localItems=array();
00083         if (($backRef->cmLevel && t3lib_div::_GP('subname')=='moreoptions') || ($table==='pages' && $uid==0))   {   // Show import/export on second level menu OR root level.
00084 
00085             $LL = $this->includeLL();
00086 
00087             $modUrl = $backRef->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php';
00088             $url = $modUrl . '?tx_impexp[action]=export&id=' . ($table == 'pages' ? $uid : $backRef->rec['pid']);
00089             if ($table=='pages')    {
00090                 $url.='&tx_impexp[pagetree][id]='.$uid;
00091                 $url.='&tx_impexp[pagetree][levels]=0';
00092                 $url.='&tx_impexp[pagetree][tables][]=_ALL';
00093             } else {
00094                 $url.='&tx_impexp[record][]='.rawurlencode($table.':'.$uid);
00095                 $url.='&tx_impexp[external_ref][tables][]=_ALL';
00096             }
00097             $localItems[] = $backRef->linkItem(
00098                 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export',$LL)),
00099                 $backRef->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-export-t3d')),
00100                 $backRef->urlRefForCM($url),
00101                 1   // Disables the item in the top-bar
00102             );
00103 
00104             if ($table=='pages')    {
00105                 $url = $modUrl . '?id='. $uid . '&table=' . $table . '&tx_impexp[action]=import';
00106                 $localItems[] = $backRef->linkItem(
00107                     $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import',$LL)),
00108                     $backRef->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-import-t3d')),
00109                     $backRef->urlRefForCM($url),
00110                     1   // Disables the item in the top-bar
00111                 );
00112             }
00113         }
00114         return array_merge($menuItems,$localItems);
00115     }
00116 
00117     /**
00118      * Include local lang file and return $LOCAL_LANG array loaded.
00119      *
00120      * @return  array       Local lang array
00121      */
00122     function includeLL()    {
00123         global $LANG;
00124 
00125         return $LANG->includeLLFile('EXT:impexp/app/locallang.php',FALSE);
00126     }
00127 }
00128 
00129 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/class.tx_impexp_clickmenu.php'])) {
00130     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/class.tx_impexp_clickmenu.php']);
00131 }
00132 ?>