class.tx_impexp_modfunc1.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (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  * Export Preset listing
00029  *
00030  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00031  */
00032 /**
00033  * [CLASS/FUNCTION INDEX of SCRIPT]
00034  *
00035  *
00036  *
00037  *   63: class tx_impexp_modfunc1 extends mod_user_task
00038  *   72:     function overview_main()
00039  *  109:     function main()
00040  *
00041  *              SECTION: Helper functions
00042  *  192:     function getPresets()
00043  *  209:     function userTempFolder()
00044  *
00045  * TOTAL FUNCTIONS: 4
00046  * (This index is automatically created/updated by the extension "extdeveval")
00047  *
00048  */
00049 
00050 
00051 
00052 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
00053 t3lib_extMgm::isLoaded('impexp',1);
00054 
00055 
00056 /**
00057  * Export Preset listing for the task center
00058  *
00059  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00060  * @package TYPO3
00061  * @subpackage tx_impexp
00062  */
00063 class tx_impexp_modfunc1 extends mod_user_task {
00064 
00065     /**
00066      * Create preset overview for task center overview.
00067      *
00068      * @param   object      Parent object
00069      * @return  string      HTML for the task center overview listing.
00070      */
00071     function overview_main()    {
00072         global $LANG;
00073             // Create preset links:
00074         $presets = $this->getPresets();
00075         $opt = array();
00076         if (is_array($presets)) {
00077             foreach($presets as $presetCfg) {
00078                 $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
00079                 $opt[] = '
00080                     <tr class="bgColor4">
00081                         <td nowrap="nowrap"><a href="index.php?SET[function]=tx_impexp&display='.$presetCfg['uid'].'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,30)).'</a>&nbsp;</td>
00082                         <td>'.($presetCfg['item_uid'] ? $presetCfg['item_uid'] : '&nbsp;').'</td>
00083                         <td>'.($presetCfg['public'] ? '[Public]' : '&nbsp;').'</td>
00084                         <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? '[Own]' : '&nbsp;').'</td>
00085                     </tr>';
00086             }
00087             if(sizeof($opt)>0) {
00088                 $presets = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
00089                 $presets .= '<a href="index.php?SET[function]=tx_impexp"><em>'.$LANG->getLL('link_allRecs').'</em></a>';
00090             } else {
00091                 $presets = '';
00092             }
00093 
00094             $icon = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath('impexp').'export.gif" width="18" height="16" class="absmiddle" alt="" />';
00095             $config= $this->mkMenuConfig($icon.$this->headLink('tx_impexp_modfunc1',1),'',$presets);
00096         }
00097 
00098         return $config;
00099     }
00100 
00101 
00102 
00103     /**
00104      * Main Task center module
00105      *
00106      * @return  string      HTML content.
00107      */
00108     function main() {
00109             if($id = t3lib_div::_GP('display')) {
00110                 return $this->urlInIframe($this->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]='.$id,1);
00111             } else {
00112                 // Thumbnail folder and files:
00113                 $tempDir = $this->userTempFolder();
00114                 if ($tempDir)   {
00115                     $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
00116                 }
00117 
00118                 $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
00119                 $usernames = t3lib_BEfunc::getUserNames();
00120 
00121                 // Create preset links:
00122                 $presets = $this->getPresets();
00123                 $opt = array();
00124                 $opt[] = '
00125             <tr class="bgColor5 tableheader">
00126                 <td>Icon:</td>
00127                 <td>Preset Title:</td>
00128                 <td>Public</td>
00129                 <td>Owner:</td>
00130                 <td>Page:</td>
00131                 <td>Path:</td>
00132                 <td>Meta data:</td>
00133             </tr>';
00134                 if (is_array($presets)) {
00135                     foreach($presets as $presetCfg) {
00136                         $configuration = unserialize($presetCfg['preset_data']);
00137                         $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
00138                         $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '['.$presetCfg['uid'].']';
00139 
00140                         $opt[] = '
00141                     <tr class="bgColor4">
00142                         <td>'.($thumbnailFile ? '<img src="'.$this->backPath.'../'.substr($tempDir,strlen(PATH_site)).basename($thumbnailFile).'" hspace="2" width="70" style="border: solid black 1px;" alt="" /><br/>' : '&nbsp;').'</td>
00143                         <td nowrap="nowrap"><a href="index.php?SET[function]=tx_impexp&display='.$presetCfg['uid'].'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,30)).'</a>&nbsp;</td>
00144                         <td>'.($presetCfg['public'] ? 'Yes' : '&nbsp;').'</td>
00145                         <td>'.($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? 'Own' : '['.$usernames[$presetCfg['user_uid']]['username'].']').'</td>
00146                         <td>'.($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : '&nbsp;').'</td>
00147                         <td>'.htmlspecialchars($configuration['pagetree']['id'] ? t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'],$clause,20) : '[Single Records]').'</td>
00148                         <td>
00149                             <b>'.htmlspecialchars($configuration['meta']['title']).'</b><br/>'.
00150                             htmlspecialchars($configuration['meta']['description']).
00151                             ($configuration['meta']['notes'] ? '<br/><br/><b>Notes:</b> <em>'.htmlspecialchars($configuration['meta']['notes']).'</em>' : '').
00152                             '
00153                         </td>
00154                     </tr>';
00155                     }
00156                     $content = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">'.implode('',$opt).'</table>';
00157                 }
00158             }
00159 
00160             // Output:
00161         $theOutput.= $this->pObj->doc->spacer(5);
00162         $theOutput.= $this->pObj->doc->section('Export presets',$content,0,1);
00163 
00164         return $theOutput;
00165     }
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180     /*****************************
00181      *
00182      * Helper functions
00183      *
00184      *****************************/
00185 
00186     /**
00187      * Select presets for this user
00188      *
00189      * @return  array       Array of preset records
00190      */
00191     function getPresets()   {
00192         $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00193                 '*',
00194                 'tx_impexp_presets',
00195                 '(public>0 || user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')',
00196                 '',
00197                 'item_uid DESC, title'
00198             );
00199 
00200         return $presets;
00201     }
00202 
00203     /**
00204      * Returns first temporary folder of the user account (from $FILEMOUNTS)
00205      *
00206      * @return  string      Absolute path to first "_temp_" folder of the current user, otherwise blank.
00207      */
00208     function userTempFolder()   {
00209         global $FILEMOUNTS;
00210 
00211         foreach($FILEMOUNTS as $filePathInfo)   {
00212             $tempFolder = $filePathInfo['path'].'_temp_/';
00213             if (@is_dir($tempFolder))   {
00214                 return $tempFolder;
00215             }
00216         }
00217     }
00218 }
00219 
00220 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php'])    {
00221     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/modfunc1/class.tx_impexp_modfunc1.php']);
00222 }
00223 ?>

Generated on Sat Jan 3 04:23:31 2009 for TYPO3 API by  doxygen 1.4.7