/**
  * Register mwEmbeed resource set 
  * 
  * Adds modules to ResourceLoader
  */
 public static function register($mwEmbedResourcePath)
 {
     global $IP, $wgExtensionMessagesFiles;
     $fullResourcePath = $IP . '/' . $mwEmbedResourcePath;
     // Get the module name from the end of the path:
     $modulePathParts = explode('/', $mwEmbedResourcePath);
     $moduleName = array_pop($modulePathParts);
     if (!is_dir($fullResourcePath)) {
         throw new MWException(__METHOD__ . " not given readable path: " . htmlspecialchars($mwEmbedResourcePath));
     }
     if (substr($mwEmbedResourcePath, -1) == '/') {
         throw new MWException(__METHOD__ . " path has trailing slash: " . htmlspecialchars($mwEmbedResourcePath));
     }
     // Add module messages if present:
     $msgFileName = $fullResourcePath . '/' . $moduleName . '.i18n';
     if (is_file($msgFileName . '.json')) {
         $wgExtensionMessagesFiles['MwEmbed.' . $moduleName] = $msgFileName . '.json';
     } elseif (is_file($msgFileName . '.php')) {
         $wgExtensionMessagesFiles['MwEmbed.' . $moduleName] = $msgFileName . '.php';
     }
     // Get the mwEmbed module resource registration:
     $moduleResourceFileName = $fullResourcePath . '/' . $moduleName;
     if (is_file($moduleResourceFileName . '.json')) {
         $resourceList = json_decode(file_get_contents($moduleResourceFileName . '.json'), TRUE);
     } else {
         $resourceList = (include $moduleResourceFileName . '.php');
     }
     // Look for special 'messages' => 'moduleFile' key and load all modules file messages:
     foreach ($resourceList as $name => $resources) {
         if (isset($resources['messageFile']) && is_file($fullResourcePath . '/' . $resources['messageFile'])) {
             $resourceList[$name]['messages'] = array();
             $ext = pathinfo($fullResourcePath . '/' . $resources['messageFile'], PATHINFO_EXTENSION);
             switch ($ext) {
                 case "json":
                     $messages = json_decode(file_get_contents($fullResourcePath . '/' . $resources['messageFile']), TRUE);
                     break;
                 case "php":
                     include $fullResourcePath . '/' . $resources['messageFile'];
                     break;
             }
             foreach ($messages['en'] as $msgKey => $na) {
                 $resourceList[$name]['messages'][] = $msgKey;
             }
         }
     }
     // Check for module loader:
     if (is_file($fullResourcePath . '/' . $moduleName . '.loader.js')) {
         $resourceList[$moduleName . '.loader'] = array('loaderScripts' => $moduleName . '.loader.js');
     }
     // Check for module config ( @@TODO support per-module config )
     $configPathFileName = $fullResourcePath . '/' . $moduleName . '.config';
     if (is_file($configPathFileName . '.json')) {
         $moduleConfigObj = json_decode(file_get_contents($configPathFileName . '.json'), TRUE);
         self::$moduleConfig = array_merge(self::$moduleConfig, $moduleConfigObj);
     } elseif (is_file($configPathFileName . '.php')) {
         self::$moduleConfig = array_merge(self::$moduleConfig, include $configPathFileName . '.php');
     }
     // Add the resource list into the module set with its provided path
     self::$moduleSet[$mwEmbedResourcePath] = $resourceList;
 }
 static function register()
 {
     global $wgParserOutputHooks, $wgHooks, $wgJobClasses, $wgJobTypesExcludedFromDefaultQueue, $wgMediaHandlers, $wgResourceModules, $wgExcludeFromThumbnailPurge, $wgExtraNamespaces, $wgTmhFileExtensions, $wgParserOutputHooks, $wgOut, $wgAPIPropModules, $wgTimedTextNS;
     // Register the Timed Media Handler javascript resources ( MwEmbed modules )
     MwEmbedResourceManager::register('extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer');
     MwEmbedResourceManager::register('extensions/TimedMediaHandler/MwEmbedModules/TimedText');
     // Set the default webPath for this embed player extension
     global $wgExtensionAssetsPath, $wgMwEmbedModuleConfig, $timedMediaDir;
     $wgMwEmbedModuleConfig['EmbedPlayer.WebPath'] = $wgExtensionAssetsPath . '/' . basename($timedMediaDir) . '/MwEmbedModules/EmbedPlayer';
     // Setup media Handlers:
     $wgMediaHandlers['application/ogg'] = 'OggHandler';
     $wgMediaHandlers['video/webm'] = 'WebMHandler';
     // Add transcode job class:
     $wgJobClasses += array('webVideoTranscode' => 'WebVideoTranscodeJob');
     // Transcode jobs must be explicitly requested from the job queue:
     $wgJobTypesExcludedFromDefaultQueue[] = 'webVideoTranscode';
     $baseExtensionResource = array('localBasePath' => dirname(__FILE__), 'remoteExtPath' => 'TimedMediaHandler');
     // Add the PopUpMediaTransform module ( specific to timedMedia handler ( no support in mwEmbed modules )
     $wgResourceModules += array('mw.PopUpMediaTransform' => array_merge($baseExtensionResource, array('scripts' => 'resources/mw.PopUpThumbVideo.js', 'styles' => 'resources/PopUpThumbVideo.css', 'dependencies' => array('jquery.ui.dialog'))), 'embedPlayerIframeStyle' => array_merge($baseExtensionResource, array('styles' => 'resources/embedPlayerIframe.css')), 'ext.tmh.transcodetable' => array_merge($baseExtensionResource, array('scripts' => 'resources/ext.tmh.transcodetable.js', 'styles' => 'resources/transcodeTable.css', 'messages' => array('mwe-ok', 'mwe-cancel', 'timedmedia-reset-error', 'timedmedia-reset', 'timedmedia-reset-confirm'))), "mw.MediaWikiPlayerSupport" => array_merge($baseExtensionResource, array('scripts' => 'resources/mw.MediaWikiPlayerSupport.js', 'dependencies' => array('mw.Api'))), "mw.MediaWikiPlayer.loader" => array_merge($baseExtensionResource, array('loaderScripts' => 'resources/mw.MediaWikiPlayer.loader.js')));
     // Setup a hook for iframe embed handling:
     $wgHooks['ArticleFromTitle'][] = 'TimedMediaIframeOutput::iframeHook';
     // When an upload completes ( check clear any existing transcodes )
     $wgHooks['UploadComplete'][] = 'TimedMediaHandlerHooks::checkUploadComplete';
     // When an image page is moved:
     $wgHooks['TitleMoveComplete'][] = 'TimedMediaHandlerHooks::checkTitleMoveComplete';
     // When image page is deleted so that we remove transcode settings / files.
     $wgHooks['ArticleDeleteComplete'][] = 'TimedMediaHandlerHooks::checkArticleDeleteComplete';
     // Add parser hook
     $wgParserOutputHooks['TimedMediaHandler'] = array('TimedMediaHandler', 'outputHook');
     // We should probably move this script output to a parser function but not working correctly in
     // dynamic contexts ( for example in special upload, when there is an "existing file" warning. )
     $wgHooks['BeforePageDisplay'][] = 'TimedMediaHandlerHooks::pageOutputHook';
     // Exclude transcoded assets from normal thumbnail purging
     // ( a maintenance script could handle transcode asset purging)
     if (isset($wgExcludeFromThumbnailPurge)) {
         $wgExcludeFromThumbnailPurge = array_merge($wgExcludeFromThumbnailPurge, $wgTmhFileExtensions);
         // Also add the .log file ( used in two pass encoding )
         // ( probably should move in-progress encodes out of web accessible directory )
         $wgExcludeFromThumbnailPurge[] = 'log';
     }
     $wgHooks['LoadExtensionSchemaUpdates'][] = 'TimedMediaHandlerHooks::loadExtensionSchemaUpdates';
     // Add unit tests
     $wgHooks['UnitTestsList'][] = 'TimedMediaHandlerHooks::registerUnitTests';
     /**
      * Add support for the "TimedText" NameSpace
      */
     define("NS_TIMEDTEXT", $wgTimedTextNS);
     define("NS_TIMEDTEXT_TALK", $wgTimedTextNS + 1);
     $wgExtraNamespaces[NS_TIMEDTEXT] = "TimedText";
     $wgExtraNamespaces[NS_TIMEDTEXT_TALK] = "TimedText_talk";
     // Check for timed text page:
     $wgHooks['ArticleFromTitle'][] = 'TimedMediaHandlerHooks::checkForTimedTextPage';
     // Add transcode status to video asset pages:
     $wgHooks['ImagePageAfterImageLinks'][] = 'TimedMediaHandlerHooks::checkForTranscodeStatus';
     // for MediaWiki 1.17 compatibility
     TranscodeStatusTable::getLinker();
     return true;
 }
 static function register()
 {
     global $wgHooks;
     // Register the core MwEmbed Support Module:
     MwEmbedResourceManager::register('extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport');
     // Register the MwEmbed 'mediaWiki' Module:
     MwEmbedResourceManager::register('extensions/MwEmbedSupport/MwEmbedModules/MediaWikiSupport');
     // Add mwEmbed Support modules that are not part of startup
     $wgHooks['BeforePageDisplay'][] = 'MwEmbedSupportHooks::UpdatePageModules';
     // Add Global MwEmbed Registration hook
     $wgHooks['ResourceLoaderRegisterModules'][] = 'MwEmbedResourceManager::registerModules';
     // Add MwEmbed module configuration
     $wgHooks['ResourceLoaderGetConfigVars'][] = 'MwEmbedResourceManager::registerConfigVars';
     // Add the startup modules hook
     $wgHooks['ResourceLoaderGetStartupModules'][] = 'MwEmbedSupportHooks::addStartupModules';
     return true;
 }
 /**
  * Register mwEmbeed resource set based on the 
  * 
  * Adds modules to ResourceLoader
  */
 public static function register($mwEmbedResourcePath)
 {
     global $IP, $wgExtensionMessagesFiles;
     $localResourcePath = $IP . '/' . $mwEmbedResourcePath;
     // Get the module name from the end of the path:
     $modulePathParts = explode('/', $mwEmbedResourcePath);
     $moduleName = array_pop($modulePathParts);
     if (!is_dir($localResourcePath)) {
         throw new MWException(__METHOD__ . " not given readable path: " . htmlspecialchars($localResourcePath));
     }
     if (substr($mwEmbedResourcePath, -1) == '/') {
         throw new MWException(__METHOD__ . " path has trailing slash: " . htmlspecialchars($localResourcePath));
     }
     // Add module messages if present:
     if (is_file($localResourcePath . '/' . $moduleName . '.i18n.php')) {
         $wgExtensionMessagesFiles['MwEmbed.' . $moduleName] = $localResourcePath . '/' . $moduleName . '.i18n.php';
     }
     // Check that resource file is present:
     $resourceListFilePath = $localResourcePath . '/' . $moduleName . '.php';
     if (!is_file($resourceListFilePath)) {
         throw new MWException(__METHOD__ . " mwEmbed Module is missing resource list: " . htmlspecialchars($resourceListFilePath));
     }
     // Get the mwEmbed module resource registration:
     $resourceList = (include $resourceListFilePath);
     // Look for special 'messages' => 'moduleFile' key and load all modules file messages:
     foreach ($resourceList as $name => $resources) {
         if (isset($resources['messageFile']) && is_file($localResourcePath . '/' . $resources['messageFile'])) {
             $resourceList[$name]['messages'] = array();
             include $localResourcePath . '/' . $resources['messageFile'];
             foreach ($messages['en'] as $msgKey => $na) {
                 $resourceList[$name]['messages'][] = $msgKey;
             }
         }
     }
     // Check for module loader:
     if (is_file($localResourcePath . '/' . $moduleName . '.loader.js')) {
         $resourceList[$moduleName . '.loader'] = array('loaderScripts' => $moduleName . '.loader.js');
     }
     // Check for module config ( @@TODO support per-module config )
     $configPath = $localResourcePath . '/' . $moduleName . '.config.php';
     if (is_file($configPath)) {
         self::$moduleConfig = array_merge(self::$moduleConfig, include $configPath);
     }
     // Add the resource list into the module set with its provided path
     self::$moduleSet[$mwEmbedResourcePath] = $resourceList;
 }
 * @file
 * @ingroup Extensions
 *
 * This file contains the include file for the Add Media Wizard support
 * The addMediaWizard is dependent on MwEmbedSupport extension
 *
 * @author Michael Dale <*****@*****.**> and others
 * @license GPL v2 or later
 * @version 0.1.1
 */
if (!defined('MEDIAWIKI')) {
    echo "This is the AddMediaWizard extension. Please see the README file for installation instructions.\n";
    exit(1);
}
if (!class_exists('MwEmbedResourceManager')) {
    echo "AddMediaWizard requires the MwEmbedSupport extension.\n";
    exit(1);
}
/* Configuration */
// Credits
$wgExtensionCredits['other'][] = array('path' => __FILE__, 'name' => 'Add Media Wizard', 'author' => array('Michael Dale'), 'version' => '0.2', 'descriptionmsg' => 'addmediawizard-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:Add_Media_Wizard');
$AMWdir = dirname(__FILE__) . '/';
$wgAutoloadClasses['AddMediaWizardHooks'] = "{$AMWdir}/AddMediaWizard.hooks.php";
$wgExtensionMessagesFiles['AddMediaWizard'] = $AMWdir . 'AddMediaWizard.i18n.php';
// Register all AddMediaWizard hooks:
AddMediaWizardHooks::register();
// Register the MwEmbed AddMedia Module:
MwEmbedResourceManager::register('extensions/AddMediaWizard/MwEmbedModules/AddMedia');
// Register the MwEmbed ClipEdit Module
MwEmbedResourceManager::register('extensions/AddMediaWizard/MwEmbedModules/ClipEdit');
Esempio n. 6
0
if (!file_exists(MW_CONFIG_FILE)) {
    print "if( console && typeof console.log == 'function' ){ console.log('MwEmbed could not find LocalSettings.php ( using default configuration )'); }\n";
} else {
    # Load local settings
    require_once "{$IP}/LocalSettings.php";
}
# Include utility files:
require_once "{$IP}/includes/Hooks.php";
/**
 * Legay mappings for mwEmbed config 
 */
if (isset($wgEnableScriptDebug)) {
    $wgResourceLoaderDebug = $wgEnableScriptDebug;
}
# Create the wgRequest global:
$wgRequest = new WebRequest();
$wgLang = new UserLang();
// Check for required module "MwEmbedSupport"
if (in_array("MwEmbedSupport", $wgMwEmbedEnabledModules) == false) {
    array_push($wgMwEmbedEnabledModules, "MwEmbedSupport");
}
# Register / load all the mwEmbed modules
foreach ($wgMwEmbedEnabledModules as $moduleName) {
    $modulePath = "modules/{$moduleName}";
    if (is_file("{$IP}/{$modulePath}/{$moduleName}.php")) {
        MwEmbedResourceManager::register($modulePath);
    }
}
# Add the resource loader hooks
$wgHooks['ResourceLoaderRegisterModules'][] = 'MwEmbedResourceManager::registerModules';
$wgHooks['ResourceLoaderGetConfigVars'][] = 'MwEmbedResourceManager::registerConfigVars';
Esempio n. 7
0
        }
        $i++;
    }
    $j = count($from) - 1;
    // Add '..' until the path is the same
    while ($i <= $j) {
        if (!empty($from[$j])) {
            $relpath .= '..' . DIRECTORY_SEPARATOR;
        }
        $j--;
    }
    // Go to folder from where it starts differing
    while (isset($to[$i])) {
        if (!empty($to[$i])) {
            $relpath .= $to[$i] . DIRECTORY_SEPARATOR;
        }
        $i++;
    }
    // Strip last separator
    return substr($relpath, 0, -1);
}
foreach ($wgKwidgetPsEnabledModules as $moduleName) {
    $modulePath = $wgKalturaPSHtml5ModulesDir . '/' . $moduleName;
    $relativeModulePath = find_relative_path($IP, $modulePath);
    if (is_file($modulePath . '/' . $moduleName . '.json')) {
        MwEmbedResourceManager::register($relativeModulePath);
    }
}
# Add the resource loader hooks
$wgHooks['ResourceLoaderRegisterModules'][] = 'MwEmbedResourceManager::registerModules';
$wgHooks['ResourceLoaderGetConfigVars'][] = 'MwEmbedResourceManager::registerConfigVars';