Removed some MS-DOS line endings from PHP files
authorErnesto Baschny <ernst@cron-it.de>
Thu, 23 Sep 2010 07:07:25 +0000 (07:07 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Thu, 23 Sep 2010 07:07:25 +0000 (07:07 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8861 709f56b5-9817-0410-a4d7-c38de5d9e867

t3lib/spritemanager/class.t3lib_spritemanager_spritegenerator.php
typo3/sysext/cms/tslib/class.tslib_mediawizardcoreprovider.php
typo3/sysext/cms/tslib/class.tslib_mediawizardmanager.php
typo3/sysext/cms/tslib/interfaces/interface.tslib_mediawizardprovider.php

index 232f11d..d5db9a4 100644 (file)
-<?php\r
-/***************************************************************\r
-*  Copyright notice\r
-*\r
-*  (c) 2010 Steffen Ritter <info@steffen-ritter.net>\r
-*  All rights reserved\r
-*\r
-*  This script is part of the TYPO3 project. The TYPO3 project is\r
-*  free software; you can redistribute it and/or modify\r
-*  it under the terms of the GNU General Public License as published by\r
-*  the Free Software Foundation; either version 2 of the License, or\r
-*  (at your option) any later version.\r
-*\r
-*  The GNU General Public License can be found at\r
-*  http://www.gnu.org/copyleft/gpl.html.\r
-*  A copy is found in the textfile GPL.txt and important notices to the license\r
-*  from the author is found in LICENSE.txt distributed with these scripts.\r
-*\r
-*\r
-*  This script is distributed in the hope that it will be useful,\r
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*  GNU General Public License for more details.\r
-*\r
-*  This copyright notice MUST APPEAR in all copies of the script!\r
-***************************************************************/\r
-\r
-\r
-/**\r
- * sprite generator\r
- *\r
- * @author     Steffen Ritter <info@steffen-ritter.net>\r
- * @package TYPO3\r
- * @subpackage t3lib\r
- */\r
-\r
-class t3lib_spritemanager_SpriteGenerator {\r
-       /**\r
-        * template creating CSS for the spritefile\r
-        *\r
-        * @var string\r
-        */\r
-       protected $templateSprite = '\r
-.###NAMESPACE###-###SPRITENAME### {\r
-       background-image: url(\'###SPRITEURL###\');\r
-       height: ###DEFAULTHEIGHT###px;\r
-       width: ###DEFAULTWIDTH###px;\r
-}\r
-';\r
-\r
-       /**\r
-        *\r
-        * template creating CSS for position and size of a single icon\r
-        *\r
-        * @var string\r
-        */\r
-       protected $templateIcon = '.###NAMESPACE###-###ICONNAME### {\r
-       background-position: -###LEFT###px -###TOP###px;\r
-       ###SIZE_INFO###\r
-}\r
-';\r
-\r
-       /**\r
-        * most common icon-width in the sprite\r
-        *\r
-        * @var int\r
-        */\r
-       protected $defaultWidth  = 0;\r
-\r
-       /**\r
-        * most common icon-height in the sprite\r
-        *\r
-        * @var int\r
-        */\r
-       protected $defaultHeight = 0;\r
-\r
-       /**\r
-        * calculated width of the sprite\r
-        *\r
-        * @var int\r
-        */\r
-       protected $spriteWidth = 0;\r
-\r
-       /**\r
-        * calculated height of the sprite\r
-        * @var int\r
-        */\r
-       protected $spriteHeight = 0;\r
-\r
-       /**\r
-        * sprite name, will be the filename, too\r
-        *\r
-        * @var string\r
-        */\r
-       protected $spriteName = '';\r
-\r
-       /**\r
-        * the folder the sprite-images will be saved (relative to PATH_site)\r
-        *\r
-        * @var string\r
-        */\r
-       protected $spriteFolder = 'typo3temp/sprites/';\r
-\r
-       /**\r
-        * the folder the sprite-cs will be saved (relative to PATH_site)\r
-        *\r
-        * @var string\r
-        */\r
-       protected $cssFolder = 'typo3temp/sprites/';\r
-\r
-       /**\r
-        * the spriteName will not be included in icon names\r
-        *\r
-        * @var boolean\r
-        */\r
-       protected $ommitSpriteNameInIconName = FALSE;\r
-\r
-       /**\r
-        * @var boolean\r
-        * @deprecated IE6 support will be dropped within 4.6 - then gifcopies are superflous\r
-        */\r
-       protected $generateGIFCopy = TRUE;\r
-\r
-       /**\r
-        * namespace of css classes\r
-        *\r
-        * @var string\r
-        */\r
-       protected $nameSpace = 't3-icon';\r
-\r
-       /**\r
-        * setting this to true, the timestamp of the creation will be included to the background import\r
-        * helps to easily rebuild sprites without cache problems\r
-        *\r
-        * @var boolean\r
-        */\r
-       protected $includeTimestampInCSS = TRUE;\r
-\r
-       /**\r
-        * all bases/root-names included in the sprite which has to be in css\r
-        * as sprite to include the background-image\r
-        *\r
-        * @var array\r
-        */\r
-       protected $spriteBases = array();\r
-\r
-       /**\r
-        * collects data about all icons to process\r
-        *\r
-        * @var array\r
-        */\r
-       protected $iconsData = array();\r
-\r
-       /**\r
-        * collects all sizes of icons within this sprite and there count\r
-        *\r
-        * @var array\r
-        */\r
-       protected $iconSizes = array();\r
-\r
-       /**\r
-        * maps icon-sizes to iconnames\r
-        *\r
-        * @var array\r
-        */\r
-       protected $iconNamesPerSize = array();\r
-\r
-       /**\r
-        * space in px between to icons in the sprite (gap)\r
-        *\r
-        * @var int\r
-        */\r
-       protected $space = 2;\r
-\r
-       /**\r
-        * Initializes the configuration of the spritegenerator\r
-        *\r
-        * @param string $spriteName    the name of the sprite to be generated\r
-        * @return void\r
-        */\r
-       public function __construct($spriteName) {\r
-               $this->spriteName = $spriteName;\r
-       }\r
-\r
-       /**\r
-        * Sets namespace of css code\r
-        *\r
-        * @param string $string\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setNamespace($nameSpace) {\r
-               $this->nameSpace = $nameSpace;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Sets the spritename\r
-        *\r
-        * @param string $spriteName    the name of the sprite to be generated\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setSpriteName($spriteName) {\r
-               $this->spriteName = $spriteName;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Sets the sprite-graphics target-folder\r
-        *\r
-        * @param string $folder the target folder where the generated sprite is stored\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setSpriteFolder($folder) {\r
-               $this->spriteFolder = $folder;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Sets the sprite-css target-folder\r
-        *\r
-        * @param string $folder the target folder where the generated CSS files are stored\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setCSSFolder($folder) {\r
-               $this->cssFolder = $folder;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Setter do enable the exclusion of the sprites-name from iconnames\r
-        *\r
-        * @param boolean $value\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setOmmitSpriteNameInIconName($value) {\r
-               $this->ommitSpriteNameInIconName = is_bool($value) ? $value : FALSE;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Setter to adjust how much space is between to icons in the sprite\r
-        *\r
-        * @param int $value\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setIconSpace($value) {\r
-               $this->space = intval($value);\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Setter to enable/disable generating a GIF-Copy of the sprite\r
-        *\r
-        * @param boolean $value\r
-        * @deprecated IE6 support will be dropped within 4.6 - then gifcopies are superflous\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setGenerateGifCopy($value) {\r
-               $this->generateGIFCopy = is_bool($value) ? $value : TRUE;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Setter for timestamp inclusion: imageFiles will be included with ?timestamp\r
-        *\r
-        * @param boolean $value\r
-        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.\r
-        */\r
-       public function setIncludeTimestampInCSS($value) {\r
-               $this->includeTimestampInCSS = is_bool($value) ? $value : TRUE;\r
-               return $this;\r
-       }\r
-\r
-       /**\r
-        * Teads all png,gif,jpg files from the passed folder name (including 1 subfolder level)\r
-        * extracts size information and stores data in internal array,\r
-        * afterwards triggers sprite generation.\r
-        *\r
-        * @param array $inputFolder folder from which files are read\r
-        * @return      array\r
-        */\r
-       public function generateSpriteFromFolder(array $inputFolder) {\r
-               $iconArray = array();\r
-               foreach ($inputFolder as $folder) {\r
-                               // detect all files to be included in sprites\r
-                       $iconArray = array_merge(\r
-                               $iconArray,\r
-                               $this->getFolder($folder)\r
-                       );\r
-               }\r
-               return $this->generateSpriteFromArray($iconArray);\r
-       }\r
-\r
-       /**\r
-        * Method processes an array of files into an sprite,\r
-        * the array can be build from files within an folder or\r
-        * by hand (as the SpriteManager does)\r
-        *\r
-        * @param array $files array(icon name => icon file)\r
-        * @return array\r
-        */\r
-       public function generateSpriteFromArray(array $files) {\r
-               if (!$this->ommitSpriteNameInIconName) {\r
-                       $this->spriteBases[] = $this->spriteName;\r
-               }\r
-\r
-               $this->buildFileInformationCache($files);\r
-                       // calculate Icon Position in sprite\r
-               $this->calculateSpritePositions();\r
-\r
-               $this->generateGraphic();\r
-\r
-               $this->generateCSS();\r
-\r
-               $iconNames = array_keys($this->iconsData);\r
-               natsort($iconNames);\r
-\r
-               return array(\r
-                       'spriteImage'   => PATH_site . $this->spriteFolder . $this->spriteName . '.png',\r
-                       'spriteGifImage'=> PATH_site . $this->spriteFolder . $this->spriteName . '.gif',\r
-                       'cssFile'               => PATH_site . $this->cssFolder . $this->spriteName . '.css',\r
-                       'cssGif'                => PATH_site . $this->cssFolder . $this->spriteName . '-ie6.css',\r
-                       'iconNames'             => $iconNames\r
-               );\r
-       }\r
-\r
-       /**\r
-        * Generates the css files\r
-        *\r
-        * @return void\r
-        */\r
-       protected function generateCSS() {\r
-               $cssData = '';\r
-               $cssIe6 = '';\r
-\r
-               if ($this->includeTimestampInCSS) {\r
-                       $timestamp = '?' . time();\r
-               } else {\r
-                       $timestamp = '';\r
-               }\r
-\r
-               $spritePathForCSS = $this->resolveSpritePath();\r
-\r
-               $markerArray = array(\r
-                       '###NAMESPACE###'               => $this->nameSpace,\r
-                       '###DEFAULTWIDTH###'    => $this->defaultWidth,\r
-                       '###DEFAULTHEIGHT###'   => $this->defaultHeight,\r
-                       '###SPRITENAME###'      => '',\r
-                       '###SPRITEURL###'               => ($spritePathForCSS ? $spritePathForCSS . '/' : '')\r
-               );\r
-               $markerArray['###SPRITEURL###'] .=  $this->spriteName . '.png' . $timestamp;\r
-\r
-               foreach ($this->spriteBases as $base) {\r
-                       $markerArray['###SPRITENAME###'] = $base;\r
-                       $cssData .= t3lib_parsehtml::substituteMarkerArray($this->templateSprite, $markerArray);\r
-               }\r
-\r
-               if ($this->generateGIFCopy) {\r
-                       $markerArray['###SPRITEURL###'] = str_replace('.png', '.gif', $markerArray['###SPRITEURL###']);\r
-                       foreach ($this->spriteBases as $base) {\r
-                               $cssIe6 .= t3lib_parsehtml::substituteMarkerArray($this->templateSprite, $markerArray);\r
-                       }\r
-               }\r
-\r
-               foreach ($this->iconsData as $key => $data) {\r
-                       $markerArrayIcons = array(\r
-                               '###NAMESPACE###'       => $this->nameSpace,\r
-                               '###ICONNAME###'        => $data['singleName'],\r
-                               '###LEFT###'            => $data['left'],\r
-                               '###TOP###'             => $data['top'],\r
-                               '###SIZE_INFO###'       => ''\r
-                       );\r
-                       if ($data['height'] != $this->defaultHeight) {\r
-                               $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'height: ' . $data['height'] . 'px;' . LF;\r
-                       }\r
-                       if ($data['width'] != $this->defaultWidth) {\r
-                               $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'width: ' . $data['width'] . 'px;' . LF;\r
-                       }\r
-                       $cssData .= t3lib_parsehtml::substituteMarkerArray($this->templateIcon, $markerArrayIcons);\r
-\r
-               }\r
-\r
-               t3lib_div::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '.css', $cssData);\r
-               if ($this->generateGIFCopy) {\r
-                       t3lib_div::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '-ie6.css', $cssIe6);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Compares image path to CSS path and creates the relative backpath from css to the sprites\r
-        *\r
-        * @return string\r
-        */\r
-       protected function resolveSpritePath() {\r
-                       // Fix window paths\r
-               $this->cssFolder = str_replace('\\', '/', $this->cssFolder);\r
-               $this->spriteFolder = str_replace('\\', '/', $this->spriteFolder);\r
-\r
-               $cssPathSegments = t3lib_div::trimExplode('/', trim($this->cssFolder, '/'));\r
-               $graphicPathSegments = t3lib_div::trimExplode('/', trim($this->spriteFolder, '/'));\r
-\r
-               $i = 0;\r
-               while (isset($cssPathSegments[$i]) && isset($graphicPathSegments[$i]) &&\r
-                               $cssPathSegments[$i] == $graphicPathSegments[$i]) {\r
-                       unset($cssPathSegments[$i]);\r
-                       unset($graphicPathSegments[$i]);\r
-                       ++$i;\r
-               }\r
-               foreach ($cssPathSegments AS $key => $value) {\r
-                       $cssPathSegments[$key] = '..';\r
-               }\r
-               $completePath = array_merge($cssPathSegments, $graphicPathSegments);\r
-               $path = implode('/', $completePath);\r
-               return t3lib_div::resolveBackPath($path);\r
-       }\r
-\r
-       /**\r
-        * The actual sprite generator, renders the command for Im/GM and executes\r
-        *\r
-        * @return void\r
-        */\r
-       protected function generateGraphic() {\r
-               $iconParameters = array();\r
-               $tempSprite = t3lib_div::tempnam($this->spriteName);\r
-\r
-               $filePath = array(\r
-                       'mainFile' => PATH_site . $this->spriteFolder . $this->spriteName . '.png',\r
-                       'gifFile'  => NULL\r
-               );\r
-                       // create black true color image with given size\r
-               $newSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);\r
-               imagesavealpha($newSprite, true);\r
-                       // make it transparent\r
-               imagefill($newSprite, 0, 0, imagecolorallocatealpha($newSprite, 0, 255, 255, 127));\r
-               foreach ($this->iconsData AS $icon) {\r
-                       $function = 'imagecreatefrom' . strtolower($icon['fileExtension']);\r
-                       if(function_exists($function)) {\r
-                               $currentIcon = $function($icon['fileName']);\r
-                               imagecopy($newSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);\r
-                       }\r
-               }\r
-               imagepng($newSprite, $tempSprite . '.png');\r
-\r
-               if ($this->generateGIFCopy) {\r
-                       $filePath['gifFile'] = PATH_site . $this->spriteFolder . $this->spriteName . '.gif';\r
-                       $gifSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);\r
-                               // make it transparent\r
-                       imagefill($gifSprite, 0, 0, imagecolorallocate($gifSprite, 127, 127, 127));\r
-                       foreach ($this->iconsData AS $icon) {\r
-                               $function = 'imagecreatefrom' . strtolower($icon['fileExtension']);\r
-                               if(function_exists($function)) {\r
-                                       $currentIcon = $function($icon['fileName']);\r
-                                       imagecopy($gifSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);\r
-                               }\r
-                       }\r
-                       imagecolortransparent($gifSprite, imagecolorallocate($gifSprite, 127, 127, 127));\r
-                       imagegif($gifSprite, $tempSprite . '.gif');\r
-               }\r
-\r
-               t3lib_div::upload_copy_move($tempSprite . '.png', $filePath['mainFile']);\r
-               t3lib_div::unlink_tempfile($tempSprite . '.png');\r
-               if ($this->generateGIFCopy) {\r
-                       t3lib_div::upload_copy_move($tempSprite . '.gif', $filePath['gifFile']);\r
-                       t3lib_div::unlink_tempfile($tempSprite . '.gif');\r
-               }\r
-       }\r
-       /**\r
-        * Arranges icons in sprites,\r
-        * afterwards all icons have information about ther position in sprite\r
-        */\r
-       protected function calculateSpritePositions() {\r
-               $currentLeft = 0;\r
-               $currentTop  = 0;\r
-                       // calculate width of every icon-size-group\r
-               $sizes = array();\r
-               foreach ($this->iconSizes as $sizeTag => $count) {\r
-                       $size = $this->explodeSizeTag($sizeTag);\r
-                       $sizes[ceil(sqrt($count)) * $size['width']] = $sizeTag;\r
-               }\r
-                       // reverse sorting: widest group to top\r
-               krsort($sizes);\r
-                       // integerate all icons grouped by icons size into the sprite\r
-               foreach ($sizes as $sizeTag) {\r
-                       $size = $this->explodeSizeTag($sizeTag);\r
-                       $currentLeft = 0;\r
-                       $rowCounter = 0;\r
-\r
-                       $rowSize = ceil(sqrt($this->iconSizes[$sizeTag]));\r
-\r
-                       $rowWidth = $rowSize * $size['width'] + ($rowSize - 1) * $this->space;\r
-                       $this->spriteWidth = ($rowWidth > $this->spriteWidth ? $rowWidth : $this->spriteWidth);\r
-                       $firstLine = TRUE;\r
-\r
-                       natsort($this->iconNamesPerSize[$sizeTag]);\r
-                       foreach ($this->iconNamesPerSize[$sizeTag] as $iconName) {\r
-                               if ($rowCounter == $rowSize - 1) {\r
-                                       $rowCounter = -1;\r
-                               } elseif ($rowCounter == 0) {\r
-                                       if (!$firstLine) {\r
-                                               $currentTop += $size['height'];\r
-                                               $currentTop += $this->space;\r
-                                       }\r
-                                       $firstLine = FALSE;\r
-                                       $currentLeft = 0;\r
-                               }\r
-                               $this->iconsData[$iconName]['left'] = $currentLeft;\r
-                               $this->iconsData[$iconName]['top']  = $currentTop;\r
-\r
-                               $currentLeft += $size['width'];\r
-                               $currentLeft += $this->space;\r
-\r
-                               $rowCounter++;\r
-                       }\r
-                       $currentTop += $size['height'];\r
-                       $currentTop += $this->space;\r
-               }\r
-               $this->spriteHeight = $currentTop;\r
-       }\r
-\r
-       /**\r
-        * Function getFolder traverses the target directory,\r
-        * locates all iconFiles and collects them into an array\r
-        *\r
-        * @param string path to an folder which contains images\r
-        * @return array returns an array with all files key: iconname, value: fileName\r
-        */\r
-       protected function getFolder($directoryPath) {\r
-               $subFolders = t3lib_div::get_dirs(PATH_site . $directoryPath);\r
-               if (!$this->ommitSpriteNameInIconName) {\r
-                       $subFolders[] = '';\r
-               }\r
-               $resultArray = array();\r
-\r
-               foreach ($subFolders as $folder) {\r
-                       if ($folder !== '.svn') {\r
-                               $icons = t3lib_div::getFilesInDir(PATH_site . $directoryPath . $folder . '/', 'gif,png,jpg');\r
-                               if (!in_array($folder, $this->spriteBases) && count($icons) && $folder !== '') {\r
-                                       $this->spriteBases[] = $folder;\r
-                               }\r
-                               foreach ($icons AS $icon) {\r
-                                       $fileInfo = pathinfo($icon);\r
-\r
-                                       $iconName = ($folder ? $folder . '-' : '') . $fileInfo['filename'];\r
-                                       if (!$this->ommitSpriteNameInIconName) {\r
-                                               $iconName = $this->spriteName . '-' . $iconName;\r
-                                       }\r
-\r
-                                       $resultArray[$iconName] = $directoryPath . $folder . '/' . $icon;\r
-                               }\r
-                       }\r
-               }\r
-               return $resultArray;\r
-       }\r
-\r
-       /**\r
-        * Generates file information cache from file array\r
-        *\r
-        * @param array list of all files with their icon name\r
-        * @return void\r
-        */\r
-       protected function buildFileInformationCache(array $files) {\r
-               foreach ($files as $iconName => $iconFile) {\r
-                       $fileInfo = pathinfo(PATH_site . $iconFile);\r
-                       $imageInfo = getimagesize(PATH_site . $iconFile);\r
-\r
-                       $this->iconsData[$iconName] = array(\r
-                               'iconName'              => $iconName,\r
-                               'singleName'    => $fileInfo['filename'],\r
-                               'fileExtension' => $fileInfo['extension'],\r
-                               'fileName'              => PATH_site . $iconFile,\r
-                               'width'                 => $imageInfo[0],\r
-                               'height'                => $imageInfo[1],\r
-                               'left'                  => 0,\r
-                               'top'                   => 0\r
-                       );\r
-\r
-                       $sizeTag = $imageInfo[0] . 'x' . $imageInfo[1];\r
-                       if (isset($this->iconSizes[$sizeTag])) {\r
-                               $this->iconSizes[$sizeTag] += 1;\r
-                       } else {\r
-                               $this->iconSizes[$sizeTag] = 1;\r
-                               $this->iconNamesPerSize[$sizeTag] = array();\r
-                       }\r
-                       $this->iconNamesPerSize[$sizeTag][] = $iconName;\r
-               }\r
-                       // find most common image size, save it as default\r
-               asort($this->iconSizes);\r
-               $defaultSize = $this->explodeSizeTag(array_pop(array_keys($this->iconSizes)));\r
-               $this->defaultWidth  = $defaultSize['width'];\r
-               $this->defaultHeight = $defaultSize['height'];\r
-       }\r
-\r
-       /**\r
-        * Transforms size tag into size array\r
-        *\r
-        * @param string  a size tag at the cache arrays\r
-        * @return array\r
-        */\r
-       protected function explodeSizeTag($tag = '') {\r
-               $size = t3lib_div::trimExplode("x", $tag);\r
-               return array(\r
-                       'width' => $size[0],\r
-                       'height'=> $size[1]\r
-               );\r
-       }\r
-\r
-}\r
-\r
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/spritemanager/class.t3lib_spritemanager_spritegenerator.php'])      {\r
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/spritemanager/class.t3lib_spritemanager_spritegenerator.php']);\r
-}\r
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2010 Steffen Ritter <info@steffen-ritter.net>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+/**
+ * sprite generator
+ *
+ * @author     Steffen Ritter <info@steffen-ritter.net>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+
+class t3lib_spritemanager_SpriteGenerator {
+       /**
+        * template creating CSS for the spritefile
+        *
+        * @var string
+        */
+       protected $templateSprite = '
+.###NAMESPACE###-###SPRITENAME### {
+       background-image: url(\'###SPRITEURL###\');
+       height: ###DEFAULTHEIGHT###px;
+       width: ###DEFAULTWIDTH###px;
+}
+';
+
+       /**
+        *
+        * template creating CSS for position and size of a single icon
+        *
+        * @var string
+        */
+       protected $templateIcon = '.###NAMESPACE###-###ICONNAME### {
+       background-position: -###LEFT###px -###TOP###px;
+       ###SIZE_INFO###
+}
+';
+
+       /**
+        * most common icon-width in the sprite
+        *
+        * @var int
+        */
+       protected $defaultWidth  = 0;
+
+       /**
+        * most common icon-height in the sprite
+        *
+        * @var int
+        */
+       protected $defaultHeight = 0;
+
+       /**
+        * calculated width of the sprite
+        *
+        * @var int
+        */
+       protected $spriteWidth = 0;
+
+       /**
+        * calculated height of the sprite
+        * @var int
+        */
+       protected $spriteHeight = 0;
+
+       /**
+        * sprite name, will be the filename, too
+        *
+        * @var string
+        */
+       protected $spriteName = '';
+
+       /**
+        * the folder the sprite-images will be saved (relative to PATH_site)
+        *
+        * @var string
+        */
+       protected $spriteFolder = 'typo3temp/sprites/';
+
+       /**
+        * the folder the sprite-cs will be saved (relative to PATH_site)
+        *
+        * @var string
+        */
+       protected $cssFolder = 'typo3temp/sprites/';
+
+       /**
+        * the spriteName will not be included in icon names
+        *
+        * @var boolean
+        */
+       protected $ommitSpriteNameInIconName = FALSE;
+
+       /**
+        * @var boolean
+        * @deprecated IE6 support will be dropped within 4.6 - then gifcopies are superflous
+        */
+       protected $generateGIFCopy = TRUE;
+
+       /**
+        * namespace of css classes
+        *
+        * @var string
+        */
+       protected $nameSpace = 't3-icon';
+
+       /**
+        * setting this to true, the timestamp of the creation will be included to the background import
+        * helps to easily rebuild sprites without cache problems
+        *
+        * @var boolean
+        */
+       protected $includeTimestampInCSS = TRUE;
+
+       /**
+        * all bases/root-names included in the sprite which has to be in css
+        * as sprite to include the background-image
+        *
+        * @var array
+        */
+       protected $spriteBases = array();
+
+       /**
+        * collects data about all icons to process
+        *
+        * @var array
+        */
+       protected $iconsData = array();
+
+       /**
+        * collects all sizes of icons within this sprite and there count
+        *
+        * @var array
+        */
+       protected $iconSizes = array();
+
+       /**
+        * maps icon-sizes to iconnames
+        *
+        * @var array
+        */
+       protected $iconNamesPerSize = array();
+
+       /**
+        * space in px between to icons in the sprite (gap)
+        *
+        * @var int
+        */
+       protected $space = 2;
+
+       /**
+        * Initializes the configuration of the spritegenerator
+        *
+        * @param string $spriteName    the name of the sprite to be generated
+        * @return void
+        */
+       public function __construct($spriteName) {
+               $this->spriteName = $spriteName;
+       }
+
+       /**
+        * Sets namespace of css code
+        *
+        * @param string $string
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setNamespace($nameSpace) {
+               $this->nameSpace = $nameSpace;
+               return $this;
+       }
+
+       /**
+        * Sets the spritename
+        *
+        * @param string $spriteName    the name of the sprite to be generated
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setSpriteName($spriteName) {
+               $this->spriteName = $spriteName;
+               return $this;
+       }
+
+       /**
+        * Sets the sprite-graphics target-folder
+        *
+        * @param string $folder the target folder where the generated sprite is stored
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setSpriteFolder($folder) {
+               $this->spriteFolder = $folder;
+               return $this;
+       }
+
+       /**
+        * Sets the sprite-css target-folder
+        *
+        * @param string $folder the target folder where the generated CSS files are stored
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setCSSFolder($folder) {
+               $this->cssFolder = $folder;
+               return $this;
+       }
+
+       /**
+        * Setter do enable the exclusion of the sprites-name from iconnames
+        *
+        * @param boolean $value
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setOmmitSpriteNameInIconName($value) {
+               $this->ommitSpriteNameInIconName = is_bool($value) ? $value : FALSE;
+               return $this;
+       }
+
+       /**
+        * Setter to adjust how much space is between to icons in the sprite
+        *
+        * @param int $value
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setIconSpace($value) {
+               $this->space = intval($value);
+               return $this;
+       }
+
+       /**
+        * Setter to enable/disable generating a GIF-Copy of the sprite
+        *
+        * @param boolean $value
+        * @deprecated IE6 support will be dropped within 4.6 - then gifcopies are superflous
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setGenerateGifCopy($value) {
+               $this->generateGIFCopy = is_bool($value) ? $value : TRUE;
+               return $this;
+       }
+
+       /**
+        * Setter for timestamp inclusion: imageFiles will be included with ?timestamp
+        *
+        * @param boolean $value
+        * @return t3lib_spritemanager_SpriteGenerator  an instance of $this, to enable chaining.
+        */
+       public function setIncludeTimestampInCSS($value) {
+               $this->includeTimestampInCSS = is_bool($value) ? $value : TRUE;
+               return $this;
+       }
+
+       /**
+        * Teads all png,gif,jpg files from the passed folder name (including 1 subfolder level)
+        * extracts size information and stores data in internal array,
+        * afterwards triggers sprite generation.
+        *
+        * @param array $inputFolder folder from which files are read
+        * @return      array
+        */
+       public function generateSpriteFromFolder(array $inputFolder) {
+               $iconArray = array();
+               foreach ($inputFolder as $folder) {
+                               // detect all files to be included in sprites
+                       $iconArray = array_merge(
+                               $iconArray,
+                               $this->getFolder($folder)
+                       );
+               }
+               return $this->generateSpriteFromArray($iconArray);
+       }
+
+       /**
+        * Method processes an array of files into an sprite,
+        * the array can be build from files within an folder or
+        * by hand (as the SpriteManager does)
+        *
+        * @param array $files array(icon name => icon file)
+        * @return array
+        */
+       public function generateSpriteFromArray(array $files) {
+               if (!$this->ommitSpriteNameInIconName) {
+                       $this->spriteBases[] = $this->spriteName;
+               }
+
+               $this->buildFileInformationCache($files);
+                       // calculate Icon Position in sprite
+               $this->calculateSpritePositions();
+
+               $this->generateGraphic();
+
+               $this->generateCSS();
+
+               $iconNames = array_keys($this->iconsData);
+               natsort($iconNames);
+
+               return array(
+                       'spriteImage'   => PATH_site . $this->spriteFolder . $this->spriteName . '.png',
+                       'spriteGifImage'=> PATH_site . $this->spriteFolder . $this->spriteName . '.gif',
+                       'cssFile'               => PATH_site . $this->cssFolder . $this->spriteName . '.css',
+                       'cssGif'                => PATH_site . $this->cssFolder . $this->spriteName . '-ie6.css',
+                       'iconNames'             => $iconNames
+               );
+       }
+
+       /**
+        * Generates the css files
+        *
+        * @return void
+        */
+       protected function generateCSS() {
+               $cssData = '';
+               $cssIe6 = '';
+
+               if ($this->includeTimestampInCSS) {
+                       $timestamp = '?' . time();
+               } else {
+                       $timestamp = '';
+               }
+
+               $spritePathForCSS = $this->resolveSpritePath();
+
+               $markerArray = array(
+                       '###NAMESPACE###'               => $this->nameSpace,
+                       '###DEFAULTWIDTH###'    => $this->defaultWidth,
+                       '###DEFAULTHEIGHT###'   => $this->defaultHeight,
+                       '###SPRITENAME###'      => '',
+                       '###SPRITEURL###'               => ($spritePathForCSS ? $spritePathForCSS . '/' : '')
+               );
+               $markerArray['###SPRITEURL###'] .=  $this->spriteName . '.png' . $timestamp;
+
+               foreach ($this->spriteBases as $base) {
+                       $markerArray['###SPRITENAME###'] = $base;
+                       $cssData .= t3lib_parsehtml::substituteMarkerArray($this->templateSprite, $markerArray);
+               }
+
+               if ($this->generateGIFCopy) {
+                       $markerArray['###SPRITEURL###'] = str_replace('.png', '.gif', $markerArray['###SPRITEURL###']);
+                       foreach ($this->spriteBases as $base) {
+                               $cssIe6 .= t3lib_parsehtml::substituteMarkerArray($this->templateSprite, $markerArray);
+                       }
+               }
+
+               foreach ($this->iconsData as $key => $data) {
+                       $markerArrayIcons = array(
+                               '###NAMESPACE###'       => $this->nameSpace,
+                               '###ICONNAME###'        => $data['singleName'],
+                               '###LEFT###'            => $data['left'],
+                               '###TOP###'             => $data['top'],
+                               '###SIZE_INFO###'       => ''
+                       );
+                       if ($data['height'] != $this->defaultHeight) {
+                               $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'height: ' . $data['height'] . 'px;' . LF;
+                       }
+                       if ($data['width'] != $this->defaultWidth) {
+                               $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'width: ' . $data['width'] . 'px;' . LF;
+                       }
+                       $cssData .= t3lib_parsehtml::substituteMarkerArray($this->templateIcon, $markerArrayIcons);
+
+               }
+
+               t3lib_div::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '.css', $cssData);
+               if ($this->generateGIFCopy) {
+                       t3lib_div::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '-ie6.css', $cssIe6);
+               }
+       }
+
+       /**
+        * Compares image path to CSS path and creates the relative backpath from css to the sprites
+        *
+        * @return string
+        */
+       protected function resolveSpritePath() {
+                       // Fix window paths
+               $this->cssFolder = str_replace('\\', '/', $this->cssFolder);
+               $this->spriteFolder = str_replace('\\', '/', $this->spriteFolder);
+
+               $cssPathSegments = t3lib_div::trimExplode('/', trim($this->cssFolder, '/'));
+               $graphicPathSegments = t3lib_div::trimExplode('/', trim($this->spriteFolder, '/'));
+
+               $i = 0;
+               while (isset($cssPathSegments[$i]) && isset($graphicPathSegments[$i]) &&
+                               $cssPathSegments[$i] == $graphicPathSegments[$i]) {
+                       unset($cssPathSegments[$i]);
+                       unset($graphicPathSegments[$i]);
+                       ++$i;
+               }
+               foreach ($cssPathSegments AS $key => $value) {
+                       $cssPathSegments[$key] = '..';
+               }
+               $completePath = array_merge($cssPathSegments, $graphicPathSegments);
+               $path = implode('/', $completePath);
+               return t3lib_div::resolveBackPath($path);
+       }
+
+       /**
+        * The actual sprite generator, renders the command for Im/GM and executes
+        *
+        * @return void
+        */
+       protected function generateGraphic() {
+               $iconParameters = array();
+               $tempSprite = t3lib_div::tempnam($this->spriteName);
+
+               $filePath = array(
+                       'mainFile' => PATH_site . $this->spriteFolder . $this->spriteName . '.png',
+                       'gifFile'  => NULL
+               );
+                       // create black true color image with given size
+               $newSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
+               imagesavealpha($newSprite, true);
+                       // make it transparent
+               imagefill($newSprite, 0, 0, imagecolorallocatealpha($newSprite, 0, 255, 255, 127));
+               foreach ($this->iconsData AS $icon) {
+                       $function = 'imagecreatefrom' . strtolower($icon['fileExtension']);
+                       if(function_exists($function)) {
+                               $currentIcon = $function($icon['fileName']);
+                               imagecopy($newSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);
+                       }
+               }
+               imagepng($newSprite, $tempSprite . '.png');
+
+               if ($this->generateGIFCopy) {
+                       $filePath['gifFile'] = PATH_site . $this->spriteFolder . $this->spriteName . '.gif';
+                       $gifSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
+                               // make it transparent
+                       imagefill($gifSprite, 0, 0, imagecolorallocate($gifSprite, 127, 127, 127));
+                       foreach ($this->iconsData AS $icon) {
+                               $function = 'imagecreatefrom' . strtolower($icon['fileExtension']);
+                               if(function_exists($function)) {
+                                       $currentIcon = $function($icon['fileName']);
+                                       imagecopy($gifSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);
+                               }
+                       }
+                       imagecolortransparent($gifSprite, imagecolorallocate($gifSprite, 127, 127, 127));
+                       imagegif($gifSprite, $tempSprite . '.gif');
+               }
+
+               t3lib_div::upload_copy_move($tempSprite . '.png', $filePath['mainFile']);
+               t3lib_div::unlink_tempfile($tempSprite . '.png');
+               if ($this->generateGIFCopy) {
+                       t3lib_div::upload_copy_move($tempSprite . '.gif', $filePath['gifFile']);
+                       t3lib_div::unlink_tempfile($tempSprite . '.gif');
+               }
+       }
+       /**
+        * Arranges icons in sprites,
+        * afterwards all icons have information about ther position in sprite
+        */
+       protected function calculateSpritePositions() {
+               $currentLeft = 0;
+               $currentTop  = 0;
+                       // calculate width of every icon-size-group
+               $sizes = array();
+               foreach ($this->iconSizes as $sizeTag => $count) {
+                       $size = $this->explodeSizeTag($sizeTag);
+                       $sizes[ceil(sqrt($count)) * $size['width']] = $sizeTag;
+               }
+                       // reverse sorting: widest group to top
+               krsort($sizes);
+                       // integerate all icons grouped by icons size into the sprite
+               foreach ($sizes as $sizeTag) {
+                       $size = $this->explodeSizeTag($sizeTag);
+                       $currentLeft = 0;
+                       $rowCounter = 0;
+
+                       $rowSize = ceil(sqrt($this->iconSizes[$sizeTag]));
+
+                       $rowWidth = $rowSize * $size['width'] + ($rowSize - 1) * $this->space;
+                       $this->spriteWidth = ($rowWidth > $this->spriteWidth ? $rowWidth : $this->spriteWidth);
+                       $firstLine = TRUE;
+
+                       natsort($this->iconNamesPerSize[$sizeTag]);
+                       foreach ($this->iconNamesPerSize[$sizeTag] as $iconName) {
+                               if ($rowCounter == $rowSize - 1) {
+                                       $rowCounter = -1;
+                               } elseif ($rowCounter == 0) {
+                                       if (!$firstLine) {
+                                               $currentTop += $size['height'];
+                                               $currentTop += $this->space;
+                                       }
+                                       $firstLine = FALSE;
+                                       $currentLeft = 0;
+                               }
+                               $this->iconsData[$iconName]['left'] = $currentLeft;
+                               $this->iconsData[$iconName]['top']  = $currentTop;
+
+                               $currentLeft += $size['width'];
+                               $currentLeft += $this->space;
+
+                               $rowCounter++;
+                       }
+                       $currentTop += $size['height'];
+                       $currentTop += $this->space;
+               }
+               $this->spriteHeight = $currentTop;
+       }
+
+       /**
+        * Function getFolder traverses the target directory,
+        * locates all iconFiles and collects them into an array
+        *
+        * @param string path to an folder which contains images
+        * @return array returns an array with all files key: iconname, value: fileName
+        */
+       protected function getFolder($directoryPath) {
+               $subFolders = t3lib_div::get_dirs(PATH_site . $directoryPath);
+               if (!$this->ommitSpriteNameInIconName) {
+                       $subFolders[] = '';
+               }
+               $resultArray = array();
+
+               foreach ($subFolders as $folder) {
+                       if ($folder !== '.svn') {
+                               $icons = t3lib_div::getFilesInDir(PATH_site . $directoryPath . $folder . '/', 'gif,png,jpg');
+                               if (!in_array($folder, $this->spriteBases) && count($icons) && $folder !== '') {
+                                       $this->spriteBases[] = $folder;
+                               }
+                               foreach ($icons AS $icon) {
+                                       $fileInfo = pathinfo($icon);
+
+                                       $iconName = ($folder ? $folder . '-' : '') . $fileInfo['filename'];
+                                       if (!$this->ommitSpriteNameInIconName) {
+                                               $iconName = $this->spriteName . '-' . $iconName;
+                                       }
+
+                                       $resultArray[$iconName] = $directoryPath . $folder . '/' . $icon;
+                               }
+                       }
+               }
+               return $resultArray;
+       }
+
+       /**
+        * Generates file information cache from file array
+        *
+        * @param array list of all files with their icon name
+        * @return void
+        */
+       protected function buildFileInformationCache(array $files) {
+               foreach ($files as $iconName => $iconFile) {
+                       $fileInfo = pathinfo(PATH_site . $iconFile);
+                       $imageInfo = getimagesize(PATH_site . $iconFile);
+
+                       $this->iconsData[$iconName] = array(
+                               'iconName'              => $iconName,
+                               'singleName'    => $fileInfo['filename'],
+                               'fileExtension' => $fileInfo['extension'],
+                               'fileName'              => PATH_site . $iconFile,
+                               'width'                 => $imageInfo[0],
+                               'height'                => $imageInfo[1],
+                               'left'                  => 0,
+                               'top'                   => 0
+                       );
+
+                       $sizeTag = $imageInfo[0] . 'x' . $imageInfo[1];
+                       if (isset($this->iconSizes[$sizeTag])) {
+                               $this->iconSizes[$sizeTag] += 1;
+                       } else {
+                               $this->iconSizes[$sizeTag] = 1;
+                               $this->iconNamesPerSize[$sizeTag] = array();
+                       }
+                       $this->iconNamesPerSize[$sizeTag][] = $iconName;
+               }
+                       // find most common image size, save it as default
+               asort($this->iconSizes);
+               $defaultSize = $this->explodeSizeTag(array_pop(array_keys($this->iconSizes)));
+               $this->defaultWidth  = $defaultSize['width'];
+               $this->defaultHeight = $defaultSize['height'];
+       }
+
+       /**
+        * Transforms size tag into size array
+        *
+        * @param string  a size tag at the cache arrays
+        * @return array
+        */
+       protected function explodeSizeTag($tag = '') {
+               $size = t3lib_div::trimExplode("x", $tag);
+               return array(
+                       'width' => $size[0],
+                       'height'=> $size[1]
+               );
+       }
+
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/spritemanager/class.t3lib_spritemanager_spritegenerator.php'])      {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/spritemanager/class.t3lib_spritemanager_spritegenerator.php']);
+}
 ?>
\ No newline at end of file
index 9703912..f1fca47 100644 (file)
-<?php\r
-/***************************************************************\r
- *  Copyright notice\r
- *\r
- *  (c) 2010 Aishwara M.B. (aishu.moorthy@gmail.com)\r
- *  All rights reserved\r
- *\r
- *  This script is part of the TYPO3 project. The TYPO3 project is\r
- *  free software; you can redistribute it and/or modify\r
- *  it under the terms of the GNU General Public License as published by\r
- *  the Free Software Foundation; either version 2 of the License, or\r
- *  (at your option) any later version.\r
- *\r
- *  The GNU General Public License can be found at\r
- *  http://www.gnu.org/copyleft/gpl.html.\r
- *  A copy is found in the textfile GPL.txt and important notices to the license\r
- *  from the author is found in LICENSE.txt distributed with these scripts.\r
- *\r
- *\r
- *  This script is distributed in the hope that it will be useful,\r
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- *  GNU General Public License for more details.\r
- *\r
- *  This copyright notice MUST APPEAR in all copies of the script!\r
- ***************************************************************/\r
-/**\r
- * Contains an implementation of the mediaWizardProvider supporting some\r
- * well known providers.\r
- *\r
- * $Id: $\r
-\r
- * @author     Aishwara M.B.<aishu.moorthy@gmail.com>\r
- * @author     Steffen Kamper <info@sk-typo3.de>\r
- * @author     Ernesto Baschny <ernst@cron-it.de>\r
- */\r
-\r
-\r
-class tslib_mediaWizardCoreProvider implements tslib_mediaWizardProvider {\r
-\r
-       /**\r
-        * @var array List of providers we can handle in this class\r
-        */\r
-       protected $providers = array(\r
-               'youtube',\r
-               'dailymotion',\r
-               'sevenload',\r
-               'vimeo',\r
-               'clipfish',\r
-               'google',\r
-               'metacafe',\r
-               'myvideo',\r
-               'liveleak',\r
-               'veoh'\r
-       );\r
-\r
-       /**\r
-        * Checks if we have a valid method for processing a given URL.\r
-        *\r
-        * This is done by analysing the hostname of the URL and checking if it contains\r
-        * any of our provider tags defined in $this->providers.\r
-        *\r
-        * @param  $url\r
-        * @return string\r
-        */\r
-       protected function getMethod($url) {\r
-               $urlInfo = @parse_url($url);\r
-               if ($urlInfo === FALSE) {\r
-                       return NULL;\r
-               }\r
-               $hostName = t3lib_div::trimExplode('.', $urlInfo['host'], TRUE);\r
-               foreach ($this->providers as $provider) {\r
-                       $functionName = 'process_' . $provider;\r
-                       if (in_array($provider, $hostName) && is_callable(array($this, $functionName))) {\r
-                               return $functionName;\r
-                       }\r
-               }\r
-               return NULL;\r
-       }\r
-\r
-       /***********************************************\r
-        *\r
-        * Implementation of tslib_mediaWizardProvider\r
-        *\r
-        ***********************************************/\r
-\r
-       /**\r
-        * @param  $url\r
-        * @return bool\r
-        * @see tslib_mediaWizardProvider::canHandle\r
-        */\r
-       public function canHandle($url) {\r
-               return ($this->getMethod($url) !== NULL);\r
-       }\r
-\r
-       /**\r
-        * @param  $url URL to rewrite\r
-        * @return string The rewritten URL\r
-        * @see tslib_mediaWizardProvider::rewriteUrl\r
-        */\r
-       public function rewriteUrl($url) {\r
-               $method = $this->getMethod($url);\r
-               return $this->$method($url);\r
-       }\r
-\r
-       /***********************************************\r
-        *\r
-        * Providers URL rewriting:\r
-        *\r
-        ***********************************************/\r
-\r
-       /**\r
-        * Parse youtube url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_youtube($url) {\r
-               $videoId = '';\r
-               if (strpos($url, '/user/') !== FALSE) {\r
-                               // it's a channel\r
-                       $parts = explode('/', $url);\r
-                       $videoId = $parts[count($parts) - 1];\r
-               } else if (preg_match('/v=([^(\&|$)]*)/', $url, $matches)) {\r
-                       $videoId = $matches[1];\r
-               }\r
-\r
-               if ($videoId) {\r
-                       $url = 'http://www.youtube.com/v/' . $videoId . '?fs=1';\r
-               }\r
-               return $url;\r
-       }\r
-\r
-       /**\r
-        * Parse dailymotion url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_dailymotion($url) {\r
-               $parts = explode('video/', $url);\r
-               $videoId = $parts[1];\r
-               if (strpos($videoId, '/') !== FALSE) {\r
-                       $videoId = substr($videoId, 0, strpos($videoId, '/'));\r
-               }\r
-               return 'http://www.dailymotion.com/swf/' . $videoId;\r
-       }\r
-\r
-       /**\r
-        * Parse sevenload url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url and preview image\r
-        */\r
-       protected function process_sevenload($url) {\r
-               $parts = explode('/', $url);\r
-               $videoId = $parts[count($parts) - 1];\r
-               if (strpos($videoId, '-') !== FALSE) {\r
-                       $videoId = substr($videoId, 0, strpos($videoId, '-'));\r
-               }\r
-               return 'http://de.sevenload.com/pl/' . $videoId . '/400x500/swf';\r
-       }\r
-\r
-       /**\r
-        * Parse vimeo url\r
-        *\r
-        * Supports:\r
-        * - http://vimeo.com/hd#<id>\r
-        * - http://vimeo.com/<id>\r
-        * - http://player.vimeo.com/video/<id>\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_vimeo($url) {\r
-               if (preg_match('/[\/#](\d+)$/', $url, $matches)) {\r
-                       $videoId = $matches[1];\r
-                       $url = 'http://vimeo.com/moogaloop.swf?&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&fullscreen=1&clip_id=' .\r
-                               $videoId;\r
-               }\r
-               return $url;\r
-       }\r
-\r
-       /**\r
-        * Parse clipfish url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_clipfish($url) {\r
-               if (preg_match('/video([^(\&|$)]*)/', $url, $matches)) {\r
-                       $parts = explode('/', $matches[1]);\r
-                       $videoId = $parts[1];\r
-                       $url = 'http://www.clipfish.de/cfng/flash/clipfish_player_3.swf?as=0&r=1&noad=1&fs=1&vid=' . $videoId;\r
-               }\r
-               return $url;\r
-       }\r
-\r
-\r
-       /**\r
-        * Parse google url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_google($url) {\r
-               if (preg_match('/docid=([^(\&|$)]*)/', $url, $matches)) {\r
-                       $videoId = $matches[1];\r
-                       $url = 'http://video.google.com/googleplayer.swf?docid=' . $videoId;\r
-               }\r
-               return $url;\r
-       }\r
-\r
-       /**\r
-        * Parse metacafe url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-\r
-       protected function process_metacafe($url) {\r
-               if (preg_match('/watch([^(\&|$)]*)/', $url, $matches)) {\r
-                       $parts = explode('/', $matches[1]);\r
-                       $videoId = $parts[1];\r
-                       $url = 'http://www.metacafe.com/fplayer/' . $videoId . '/.swf';\r
-               }\r
-               return $url;\r
-       }\r
-\r
-       /**\r
-        * Parse myvideo url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-\r
-       protected function process_myvideo($url) {\r
-               preg_match('/watch([^(\&|$)]*)/', $url, $matches);\r
-               $parts = explode('/', $matches[1]);\r
-               $videoId = $parts[1];\r
-\r
-               return 'http://www.myvideo.de/movie/' . $videoId . '/';\r
-       }\r
-\r
-\r
-       /**\r
-        * Parse liveleak url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_liveleak($url) {\r
-               preg_match('/i=([^(\&|$)]*)/', $url, $matches);\r
-               $videoId = $matches[1];\r
-\r
-               return 'http://www.liveleak.com/e/' . $videoId;\r
-       }\r
-\r
-       /**\r
-        * Parse veoh url\r
-        *\r
-        * @param string $url\r
-        * @return string processed url\r
-        */\r
-       protected function process_veoh($url) {\r
-               preg_match('/watch\/([^(\&|$)]*)/', $url, $matches);\r
-               $videoId = $matches[1];\r
-\r
-               return 'http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.5.2.1001&permalinkId=' . $videoId;\r
-       }\r
-\r
-}\r
-\r
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardcoreprovider.php']) {\r
-       include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardcoreprovider.php']);\r
-}\r
-\r
-?>\r
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2010 Aishwara M.B. (aishu.moorthy@gmail.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Contains an implementation of the mediaWizardProvider supporting some
+ * well known providers.
+ *
+ * $Id: $
+
+ * @author     Aishwara M.B.<aishu.moorthy@gmail.com>
+ * @author     Steffen Kamper <info@sk-typo3.de>
+ * @author     Ernesto Baschny <ernst@cron-it.de>
+ */
+
+
+class tslib_mediaWizardCoreProvider implements tslib_mediaWizardProvider {
+
+       /**
+        * @var array List of providers we can handle in this class
+        */
+       protected $providers = array(
+               'youtube',
+               'dailymotion',
+               'sevenload',
+               'vimeo',
+               'clipfish',
+               'google',
+               'metacafe',
+               'myvideo',
+               'liveleak',
+               'veoh'
+       );
+
+       /**
+        * Checks if we have a valid method for processing a given URL.
+        *
+        * This is done by analysing the hostname of the URL and checking if it contains
+        * any of our provider tags defined in $this->providers.
+        *
+        * @param  $url
+        * @return string
+        */
+       protected function getMethod($url) {
+               $urlInfo = @parse_url($url);
+               if ($urlInfo === FALSE) {
+                       return NULL;
+               }
+               $hostName = t3lib_div::trimExplode('.', $urlInfo['host'], TRUE);
+               foreach ($this->providers as $provider) {
+                       $functionName = 'process_' . $provider;
+                       if (in_array($provider, $hostName) && is_callable(array($this, $functionName))) {
+                               return $functionName;
+                       }
+               }
+               return NULL;
+       }
+
+       /***********************************************
+        *
+        * Implementation of tslib_mediaWizardProvider
+        *
+        ***********************************************/
+
+       /**
+        * @param  $url
+        * @return bool
+        * @see tslib_mediaWizardProvider::canHandle
+        */
+       public function canHandle($url) {
+               return ($this->getMethod($url) !== NULL);
+       }
+
+       /**
+        * @param  $url URL to rewrite
+        * @return string The rewritten URL
+        * @see tslib_mediaWizardProvider::rewriteUrl
+        */
+       public function rewriteUrl($url) {
+               $method = $this->getMethod($url);
+               return $this->$method($url);
+       }
+
+       /***********************************************
+        *
+        * Providers URL rewriting:
+        *
+        ***********************************************/
+
+       /**
+        * Parse youtube url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_youtube($url) {
+               $videoId = '';
+               if (strpos($url, '/user/') !== FALSE) {
+                               // it's a channel
+                       $parts = explode('/', $url);
+                       $videoId = $parts[count($parts) - 1];
+               } else if (preg_match('/v=([^(\&|$)]*)/', $url, $matches)) {
+                       $videoId = $matches[1];
+               }
+
+               if ($videoId) {
+                       $url = 'http://www.youtube.com/v/' . $videoId . '?fs=1';
+               }
+               return $url;
+       }
+
+       /**
+        * Parse dailymotion url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_dailymotion($url) {
+               $parts = explode('video/', $url);
+               $videoId = $parts[1];
+               if (strpos($videoId, '/') !== FALSE) {
+                       $videoId = substr($videoId, 0, strpos($videoId, '/'));
+               }
+               return 'http://www.dailymotion.com/swf/' . $videoId;
+       }
+
+       /**
+        * Parse sevenload url
+        *
+        * @param string $url
+        * @return string processed url and preview image
+        */
+       protected function process_sevenload($url) {
+               $parts = explode('/', $url);
+               $videoId = $parts[count($parts) - 1];
+               if (strpos($videoId, '-') !== FALSE) {
+                       $videoId = substr($videoId, 0, strpos($videoId, '-'));
+               }
+               return 'http://de.sevenload.com/pl/' . $videoId . '/400x500/swf';
+       }
+
+       /**
+        * Parse vimeo url
+        *
+        * Supports:
+        * - http://vimeo.com/hd#<id>
+        * - http://vimeo.com/<id>
+        * - http://player.vimeo.com/video/<id>
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_vimeo($url) {
+               if (preg_match('/[\/#](\d+)$/', $url, $matches)) {
+                       $videoId = $matches[1];
+                       $url = 'http://vimeo.com/moogaloop.swf?&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&fullscreen=1&clip_id=' .
+                               $videoId;
+               }
+               return $url;
+       }
+
+       /**
+        * Parse clipfish url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_clipfish($url) {
+               if (preg_match('/video([^(\&|$)]*)/', $url, $matches)) {
+                       $parts = explode('/', $matches[1]);
+                       $videoId = $parts[1];
+                       $url = 'http://www.clipfish.de/cfng/flash/clipfish_player_3.swf?as=0&r=1&noad=1&fs=1&vid=' . $videoId;
+               }
+               return $url;
+       }
+
+
+       /**
+        * Parse google url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_google($url) {
+               if (preg_match('/docid=([^(\&|$)]*)/', $url, $matches)) {
+                       $videoId = $matches[1];
+                       $url = 'http://video.google.com/googleplayer.swf?docid=' . $videoId;
+               }
+               return $url;
+       }
+
+       /**
+        * Parse metacafe url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+
+       protected function process_metacafe($url) {
+               if (preg_match('/watch([^(\&|$)]*)/', $url, $matches)) {
+                       $parts = explode('/', $matches[1]);
+                       $videoId = $parts[1];
+                       $url = 'http://www.metacafe.com/fplayer/' . $videoId . '/.swf';
+               }
+               return $url;
+       }
+
+       /**
+        * Parse myvideo url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+
+       protected function process_myvideo($url) {
+               preg_match('/watch([^(\&|$)]*)/', $url, $matches);
+               $parts = explode('/', $matches[1]);
+               $videoId = $parts[1];
+
+               return 'http://www.myvideo.de/movie/' . $videoId . '/';
+       }
+
+
+       /**
+        * Parse liveleak url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_liveleak($url) {
+               preg_match('/i=([^(\&|$)]*)/', $url, $matches);
+               $videoId = $matches[1];
+
+               return 'http://www.liveleak.com/e/' . $videoId;
+       }
+
+       /**
+        * Parse veoh url
+        *
+        * @param string $url
+        * @return string processed url
+        */
+       protected function process_veoh($url) {
+               preg_match('/watch\/([^(\&|$)]*)/', $url, $matches);
+               $videoId = $matches[1];
+
+               return 'http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.5.2.1001&permalinkId=' . $videoId;
+       }
+
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardcoreprovider.php']) {
+       include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardcoreprovider.php']);
+}
+
+?>
index 9799b5e..15fad73 100644 (file)
@@ -1,83 +1,83 @@
-<?php\r
-/***************************************************************\r
- *  Copyright notice\r
- *\r
- *  (c) 2010 Ernesto Baschny <ernst@cron-it.de>\r
- *  All rights reserved\r
- *\r
- *  This script is part of the TYPO3 project. The TYPO3 project is\r
- *  free software; you can redistribute it and/or modify\r
- *  it under the terms of the GNU General Public License as published by\r
- *  the Free Software Foundation; either version 2 of the License, or\r
- *  (at your option) any later version.\r
- *\r
- *  The GNU General Public License can be found at\r
- *  http://www.gnu.org/copyleft/gpl.html.\r
- *  A copy is found in the textfile GPL.txt and important notices to the license\r
- *  from the author is found in LICENSE.txt distributed with these scripts.\r
- *\r
- *\r
- *  This script is distributed in the hope that it will be useful,\r
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- *  GNU General Public License for more details.\r
- *\r
- *  This copyright notice MUST APPEAR in all copies of the script!\r
- ***************************************************************/\r
-\r
-/**\r
- * Manager to register and call registered media wizard providers\r
- *\r
- * $Id: $\r
-\r
- * @author     Ernesto Baschny <ernst@cron-it.de>\r
- * @static\r
- */\r
-class tslib_mediaWizardManager {\r
-\r
-       protected static $providers = array();\r
-\r
-       /**\r
-        * Allows extensions to register themselves as media wizard providers\r
-        *\r
-        * @param       string  $className A class implementing tslib_mediaWizardProvider\r
-        * @return      void\r
-        */\r
-       public static function registerMediaWizardProvider($className) {\r
-               if (!isset(self::$providers[$className])) {\r
-                       $provider = t3lib_div::makeInstance($className);\r
-                       if (!($provider instanceof tslib_mediaWizardProvider)) {\r
-                               throw new UnexpectedValueException(\r
-                                       $className .' is registered as a mediaWizardProvider, so it must implement interface tslib_mediaWizardProvider',\r
-                                       1285022360\r
-                               );\r
-                       }\r
-                       self::$providers[$className] = $provider;\r
-               }\r
-       }\r
-\r
-       /**\r
-        *\r
-        * @param string $url\r
-        * @return a valid mediaWizardProvider that can handle this URL\r
-        */\r
-       public static function getValidMediaWizardProvider($url) {\r
-                       // Go through registered providers in reverse order (last one registered wins)\r
-               $providers = array_reverse(self::$providers, TRUE);\r
-               foreach (self::$providers as $className => $provider) {\r
-                       /** @var $provider tslib_mediaWizardProvider */\r
-                       if ($provider->canHandle($url)) {\r
-                               return $provider;\r
-                       }\r
-               }\r
-                       // no provider found\r
-               return NULL;\r
-       }\r
-\r
-}\r
-\r
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardmanager.php']) {\r
-       include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardmanager.php']);\r
-}\r
-\r
-?>\r
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2010 Ernesto Baschny <ernst@cron-it.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Manager to register and call registered media wizard providers
+ *
+ * $Id: $
+
+ * @author     Ernesto Baschny <ernst@cron-it.de>
+ * @static
+ */
+class tslib_mediaWizardManager {
+
+       protected static $providers = array();
+
+       /**
+        * Allows extensions to register themselves as media wizard providers
+        *
+        * @param       string  $className A class implementing tslib_mediaWizardProvider
+        * @return      void
+        */
+       public static function registerMediaWizardProvider($className) {
+               if (!isset(self::$providers[$className])) {
+                       $provider = t3lib_div::makeInstance($className);
+                       if (!($provider instanceof tslib_mediaWizardProvider)) {
+                               throw new UnexpectedValueException(
+                                       $className .' is registered as a mediaWizardProvider, so it must implement interface tslib_mediaWizardProvider',
+                                       1285022360
+                               );
+                       }
+                       self::$providers[$className] = $provider;
+               }
+       }
+
+       /**
+        *
+        * @param string $url
+        * @return a valid mediaWizardProvider that can handle this URL
+        */
+       public static function getValidMediaWizardProvider($url) {
+                       // Go through registered providers in reverse order (last one registered wins)
+               $providers = array_reverse(self::$providers, TRUE);
+               foreach (self::$providers as $className => $provider) {
+                       /** @var $provider tslib_mediaWizardProvider */
+                       if ($provider->canHandle($url)) {
+                               return $provider;
+                       }
+               }
+                       // no provider found
+               return NULL;
+       }
+
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardmanager.php']) {
+       include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardmanager.php']);
+}
+
+?>
index 2830c34..afc25bd 100644 (file)
@@ -1,55 +1,55 @@
-<?php\r
-/***************************************************************\r
-*  Copyright notice\r
-*\r
-*  (c) 2010 Ernesto Baschny <ernst@cron-it.de>\r
-*  All rights reserved\r
-*\r
-*  This script is part of the TYPO3 project. The TYPO3 project is\r
-*  free software; you can redistribute it and/or modify\r
-*  it under the terms of the GNU General Public License as published by\r
-*  the Free Software Foundation; either version 2 of the License, or\r
-*  (at your option) any later version.\r
-*\r
-*  The GNU General Public License can be found at\r
-*  http://www.gnu.org/copyleft/gpl.html.\r
-*  A copy is found in the textfile GPL.txt and important notices to the license\r
-*  from the author is found in LICENSE.txt distributed with these scripts.\r
-*\r
-*\r
-*  This script is distributed in the hope that it will be useful,\r
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*  GNU General Public License for more details.\r
-*\r
-*  This copyright notice MUST APPEAR in all copies of the script!\r
-***************************************************************/\r
-/**\r
- * interface for classes which hook into tslib_mediawizard adding additional\r
- * media wizard providers\r
- *\r
- * @author     Ernesto Baschny <ernst@cron-it.de>\r
- * @package TYPO3\r
- * @subpackage tslib\r
- */\r
-interface tslib_mediaWizardProvider {\r
-\r
-       /**\r
-        * Tells the calling party if we can handle the URL passed to the constructor\r
-        *\r
-        * @param       string  URL to be handled\r
-        * @return      boolean\r
-        */\r
-       public function canHandle($url);\r
-\r
-       /**\r
-        * Rewrites a media provider URL into a canonized form that can be embedded\r
-        *\r
-        * @param       string  URL to be handled\r
-        * @return      string  canonized URL that can be used to embedd\r
-        */\r
-       public function rewriteUrl($url);\r
-\r
-}\r
-\r
-?>\r
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2010 Ernesto Baschny <ernst@cron-it.de>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * interface for classes which hook into tslib_mediawizard adding additional
+ * media wizard providers
+ *
+ * @author     Ernesto Baschny <ernst@cron-it.de>
+ * @package TYPO3
+ * @subpackage tslib
+ */
+interface tslib_mediaWizardProvider {
+
+       /**
+        * Tells the calling party if we can handle the URL passed to the constructor
+        *
+        * @param       string  URL to be handled
+        * @return      boolean
+        */
+       public function canHandle($url);
+
+       /**
+        * Rewrites a media provider URL into a canonized form that can be embedded
+        *
+        * @param       string  URL to be handled
+        * @return      string  canonized URL that can be used to embedd
+        */
+       public function rewriteUrl($url);
+
+}
+
+?>