TYPO3 API  SVNRelease
class.tx_impexp_task.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
00006 *  (c) 2010-2011 Georg Ringer (typo3@ringerge.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 *
00018 *  This script is distributed in the hope that it will be useful,
00019 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 *  GNU General Public License for more details.
00022 *
00023 *  This copyright notice MUST APPEAR in all copies of the script!
00024 ***************************************************************/
00025 
00026 
00027 /**
00028  * This class provides a textarea to save personal notes
00029  *
00030  * @author      Kasper Skårhøj <kasper@typo3.com>
00031  * @author      Georg Ringer <typo3@ringerge.org>
00032  * @package     TYPO3
00033  * @subpackage  impexp
00034  *
00035  */
00036 class tx_impexp_task implements tx_taskcenter_Task {
00037     /**
00038      * Back-reference to the calling reports module
00039      *
00040      * @var tx_reports_Module   $taskObject
00041      */
00042     protected $taskObject;
00043 
00044     /**
00045      * Constructor
00046      */
00047     public function __construct(SC_mod_user_task_index $taskObject) {
00048         $this->taskObject = $taskObject;
00049         $GLOBALS['LANG']->includeLLFile('EXT:impexp/locallang_csh.xml');
00050     }
00051 
00052     /**
00053      * This method renders the report
00054      *
00055      * @return  string  The status report as HTML
00056      */
00057     public function getTask() {
00058         return $this->main();
00059     }
00060 
00061     /**
00062      * Render an optional additional information for the 1st view in taskcenter.
00063      * Empty for this task
00064      *
00065      * @return  string      Overview as HTML
00066      */
00067     public function getOverview() {
00068         return '';
00069     }
00070 
00071     /**
00072      * Main Task center module
00073      *
00074      * @return  string      HTML content.
00075      */
00076     public function main() {
00077         $content = '';
00078         $id = intval(t3lib_div::_GP('display'));
00079 
00080             // if a preset is found, it is rendered using an iframe
00081         if($id > 0) {
00082             $url = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id;
00083             return $this->taskObject->urlInIframe($url, 1);
00084         } else {
00085                 // header
00086             $content .= $this->taskObject->description(
00087                 $GLOBALS['LANG']->getLL('.alttitle'),
00088                 $GLOBALS['LANG']->getLL('.description')
00089             );
00090 
00091             $thumbnails = $lines = array();
00092 
00093                 // Thumbnail folder and files:
00094             $tempDir = $this->userTempFolder();
00095             if ($tempDir) {
00096                 $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1);
00097             }
00098 
00099             $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
00100             $usernames = t3lib_BEfunc::getUserNames();
00101 
00102                 // Create preset links:
00103             $presets = $this->getPresets();
00104 
00105                 // if any presets found
00106             if (is_array($presets)) {
00107                 foreach($presets as $key => $presetCfg) {
00108                     $configuration = unserialize($presetCfg['preset_data']);
00109                     $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
00110                     $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
00111                     $icon = 'EXT:impexp/export.gif';
00112 
00113                     $description = array();
00114 
00115                         // is public?
00116                     if ($presetCfg['public']) {
00117                         $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
00118                     }
00119 
00120                         // owner
00121                     $description[] = $GLOBALS['LANG']->getLL('task.owner') . ': ' . (($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid']) ? $GLOBALS['LANG']->getLL('task.own') : '[' . htmlspecialchars($usernames[$presetCfg['user_uid']]['username']) . ']');
00122 
00123                         // page & path
00124                     if ($configuration['pagetree']['id']) {
00125                         $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id'];
00126                         $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'], $clause, 20));
00127                     } else {
00128                         $description[] = $GLOBALS['LANG']->getLL('single-record');
00129                     }
00130 
00131                         // Meta information
00132                     if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) {
00133                         $metaInformation = '';
00134                         if ($configuration['meta']['title']) {
00135                             $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />';
00136                         }
00137                         if ($configuration['meta']['description']) {
00138                             $metaInformation .= htmlspecialchars($configuration['meta']['description']);
00139                         }
00140                         if ($configuration['meta']['notes']) {
00141                             $metaInformation .= '<br /><br />
00142                                                 <strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong>
00143                                                 <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>';
00144                         }
00145 
00146                         $description[] = '<br />' . $metaInformation;
00147                     }
00148 
00149                         // collect all preset information
00150                     $lines[$key] = array(
00151                         'icon'              => $icon,
00152                         'title'             => $title,
00153                         'descriptionHtml'   => implode('<br />', $description),
00154                         'link'              => 'mod.php?M=user_task&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']
00155                     );
00156 
00157                 }
00158 
00159                     // render preset list
00160                 $content .= $this->taskObject->renderListMenu($lines);
00161             } else {
00162                     // no presets found
00163                 $flashMessage = t3lib_div::makeInstance(
00164                     't3lib_FlashMessage',
00165                     $GLOBALS['LANG']->getLL('no-presets'),
00166                     '',
00167                     t3lib_FlashMessage::NOTICE
00168                 );
00169                 $content .= $flashMessage->render();
00170             }
00171         }
00172 
00173         return $content;
00174     }
00175 
00176 
00177     /**
00178      * Select presets for this user
00179      *
00180      * @return  array       Array of preset records
00181      */
00182     protected function getPresets() {
00183         $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00184             '*',
00185             'tx_impexp_presets',
00186             '(public > 0 OR user_uid=' . $GLOBALS['BE_USER']->user['uid'] . ')',
00187             '',
00188             'item_uid DESC, title'
00189         );
00190 
00191         return $presets;
00192     }
00193 
00194     /**
00195      * Returns first temporary folder of the user account (from $FILEMOUNTS)
00196      *
00197      * @return  string      Absolute path to first "_temp_" folder of the current user, otherwise blank.
00198      */
00199     protected function userTempFolder() {
00200         foreach($GLOBALS['FILEMOUNTS'] as $filePathInfo) {
00201             $tempFolder = $filePathInfo['path'] . '_temp_/';
00202             if (@is_dir($tempFolder)) {
00203                 return $tempFolder;
00204             }
00205         }
00206 
00207         return '';
00208     }
00209 
00210 }
00211 
00212 
00213 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/task/class.tx_impexp_task.php'])) {
00214     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/task/class.tx_impexp_task.php']);
00215 }
00216 
00217 ?>