Fixed bug #15580: Add calls to logDeprecatedFunction() for more deprecated functions...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_mediawizardmanager.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Ernesto Baschny <ernst@cron-it.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Manager to register and call registered media wizard providers
30 *
31 * $Id: $
32
33 * @author Ernesto Baschny <ernst@cron-it.de>
34 * @static
35 */
36 class tslib_mediaWizardManager {
37
38 protected static $providers = array();
39
40 /**
41 * Allows extensions to register themselves as media wizard providers
42 *
43 * @param string $className A class implementing tslib_mediaWizardProvider
44 * @return void
45 */
46 public static function registerMediaWizardProvider($className) {
47 if (!isset(self::$providers[$className])) {
48 $provider = t3lib_div::makeInstance($className);
49 if (!($provider instanceof tslib_mediaWizardProvider)) {
50 throw new UnexpectedValueException(
51 $className .' is registered as a mediaWizardProvider, so it must implement interface tslib_mediaWizardProvider',
52 1285022360
53 );
54 }
55 self::$providers[$className] = $provider;
56 }
57 }
58
59 /**
60 *
61 * @param string $url
62 * @return a valid mediaWizardProvider that can handle this URL
63 */
64 public static function getValidMediaWizardProvider($url) {
65 // Go through registered providers in reverse order (last one registered wins)
66 $providers = array_reverse(self::$providers, TRUE);
67 foreach (self::$providers as $className => $provider) {
68 /** @var $provider tslib_mediaWizardProvider */
69 if ($provider->canHandle($url)) {
70 return $provider;
71 }
72 }
73 // no provider found
74 return NULL;
75 }
76
77 }
78
79 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardmanager.php']) {
80 include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_mediawizardmanager.php']);
81 }
82
83 ?>