/modules/media/bpm_audio_embed/loader.php
PHP | 792 lines | 289 code | 197 blank | 306 comment | 34 complexity | e988477dc592c0f691749ed6b9b1741e MD5 | raw file
Possible License(s): AGPL-1.0, Apache-2.0, GPL-2.0, LGPL-2.1
- <?php
- /**
- * MEDIA MODULE - BPM Embedded Audio
- *
- * @version 0.1.9
- * @since 0.1.9
- * @package BP-Media
- * @subpackage Media Modules
- * @license GPL v2.0
- * @link http://code.google.com/p/buddypress-media/
- *
- * ========================================================================================================
- */
- class BPMM_audioEmbed extends BPM_mediaModule_base implements iBPM_mediaModule {
- var $name = "Audio - Embed"; // Human readable name for this module
- var $slug = "bpm_audio_embed"; // Internal slug for this module
- // ============================================================================================================ //
- /**
- * Returns the human-readable name of the media module. This is displayed in the admin interface.
- * Example: "Video Gallery"
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | Media module admin name
- */
- public function getName(){
- return $this->name;
- }
- /**
- * Returns the url-safe slug for the media module. Must be unique from all other
- * media modules installed on the system. Example: "bpm_photo"
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | Media module slug
- */
- public function getSlug(){
- return $this->slug;
- }
- /**
- * Returns the guid of the media module as assigned by the database
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return int | Media module id
- */
- public function getId(){
- global $bpm;
- $result = $bpm->mediaModules->getBySlug( $this->slug );
- return $result["module_id"];
- }
- /**
- * Returns the HTTP path to the module's icon. Icons MUST be 64px*64px .PNG files.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | path to icon file
- */
- public function getIconPath(){
- return BPM_URL_BASE . "/modules/media/bpm_audio_embed/admin/icon.png";
- }
- /**
- * Returns a short (30 words) description of what the media module does.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | description
- */
- public function getDesc(){
- return __("The embedded audio module lets BP-Media embed streaming audio files from any website that has
- oEmbed capability, including SoundCloud, AudioFarm, and ccMixter.","bp-media");
- }
- /**
- * Returns the media module's version number. 64 chars max.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | version number
- */
- public static function getVersion(){
- return "0.1.0";
- }
- /**
- * Returns a composited HTML string, including the name of the content module developer
- * and a link to their personal or company website.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | version number
- */
- public function getAuthor(){
- return "<a href='http://code.google.com/p/buddypress-media/'>The BP-Media Team</a>";
- }
- /**
- * Returns a composited HTML string containing a link to the media module's support page, or dedicated
- * project site. Example: <a href='http://code.google.com/p/buddypress-media/'>The BP-Media Team</a>
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | version number
- */
- public static function getSite(){
- return "<a href='http://code.google.com/p/buddypress-media/'>Support Forum</a>";
- }
- /**
- * Performs all of the media module's installation operations
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return bool | True on success. False on failure.
- */
- public function install(){
- global $bpm;
- // Load the base install classes
- $bpm->config->installMode();
- $cls = new BPM_mediaModule_install_base( $slug=self::getSlug(), $name=self::getName(), $php_class=get_class($this) );
- // Add 'settings' page keys and set default values
- $settings_ok = $cls->settings($error);
- if(!$settings_ok){
- $error_string = "Media module install error during 'settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Add 'templates' page keys and set default values
- $templates_ok = $cls->templates($error);
- if(!$settings_ok){
- $error_string = "Media module install error during 'templates'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
-
- // Add module-specific keys
- // ============================================
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="actionName",
- $val="Embedded Audio",
- $filter="i18nString",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="actionDescription",
- $val="Embed an audio file from another website",
- $filter="i18nString",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbMasterX",
- $val=640,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbMasterY",
- $val=640,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbFormat",
- $val="JPG",
- $filter="textAndNumbers",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbQuality",
- $val=80,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbDefaultPath",
- $val= BPM_PATH_MEDIA_MODULES . "/" . self::getSlug(). "/templates/default_thumb.png",
- $filter="fileStringLocal",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="enabledHosts",
- $val=array(
- "ccMixter"=>true,
- "SoundCloud"=>true,
- "AudioFarm"=>true
- ),
- $filter="arraySimple",
- $ctrl=null,
- $error=null)
- ) { $result[] = $key; }
- if( count($result) == 0) {
- $custom_ok = true;
- }
- else {
- $custom_ok = false;
- $error_string = "Media module install error during 'custom settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $result) . "\n";
- trigger_error($error_string);
- }
- // Activate the module and return result
- if($settings_ok && $templates_ok && $custom_ok){
- $activate_ok = $bpm->mediaModules->activateBySlug( self::getSlug() );
- return $activate_ok;
- }
- else {
- return false;
- }
- }
- /**
- * Performs all of the media module's uninstallation operations. Completely
- * removes the module from the system, and deletes all items stored within
- * medias that this module owns.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return bool | True on success. False on failure.
- */
- public function uninstall(){
- global $bpm;
- // Load the base uninstall classes
- $bpm->config->uninstallMode();
- $cls = new BPM_mediaModule_uninstall_base( $slug=self::getSlug(), $name=self::getName(), $php_class=get_class($this) );
- // Remove 'settings' page keys
- $settings_ok = $cls->settings($error);
- if(!$settings_ok){
- $error_string = "Media module uninstall error during 'settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Remove 'templates' page keys
- $templates_ok = $cls->templates($error);
- if(!$settings_ok){
- $error_string = "Media module uninstall error during 'templates'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Remove module-specific keys
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="actionName")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="actionDescription")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbMasterX")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbMasterY")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbFormat")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbQuality")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="thumbDefaultPath")
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="mediaModules",
- $branch = self::getSlug(),
- $key="enabledHosts")
- ) { $result[] = $key; }
- if( count($result) == 0) {
- $custom_ok = true;
- }
- else {
- $custom_ok = false;
- $error_string = "Media module uninstall error during 'custom settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $result) . "\n";
- trigger_error($error_string);
- }
- // Delete the module's content and return result
- if($settings_ok && $templates_ok && $custom_ok){
- // Delete all of the module's albums, items, and content
- $delete_ok = $bpm->mediaModules->deleteBySlug( self::getSlug() );
- return $delete_ok;
- }
- else {
- return false;
- }
- }
- /**
- * Adds scripts used by the media module to the admin page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $tab | Name of the admin tab the plugin is rendering
- */
- public function enqueueAdminScripts($tab){
- // BP-Media has centralized script management. See: /core/js/register.scripts.php
- // ==============================================================================
- // Loading a custom script
- // ===============================================
- // $file_path = BPM_URL_MEDIA_MODULES . "/" . self::getSlug() . "/admin/transcoder.js";
- // wp_register_script('BPMM_tab_transcoder', $file_path);
- // wp_enqueue_script( 'BPMM_tab_transcoder');
- switch($tab) {
- case "BPMM_tab_settings" : {
- } break;
- // Handle landing on default tab
- case null : {
- } break;
- // Handle all other tabs
- default : {
- } break;
- }
- }
- /**
- * Adds CSS styles used by the media module to the admin page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $tab | Name of the admin tab the plugin is rendering
- */
- public function enqueueAdminStyles($tab){
- // Enqueue a custom style
- // ==============================================================================
- // $file_path = BPM_URL_MEDIA_MODULES . "/" . self::getSlug() . "/admin/transcoder.css";
- // wp_enqueue_style( self::getSlug(), $file_path, false, '2.8.1', 'screen' );
- switch($tab) {
- case "BPMM_tab_settings" : {
- } break;
- // Handle landing on default tab
- case null : {
- } break;
- // Handle all other tabs
- default : {
- } break;
- }
- }
- /**
- * Adds scripts used by the media module to the site page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $page | Name of the site page the plugin is rendering
- */
- public function enqueueSiteScripts($page){
- return $page;
- }
- /**
- * Adds CSS styles used by the media module to the site page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $page | Name of the site page the plugin is rendering
- */
- public function enqueueSiteStyles($page){
- return $page;
- }
- /**
- * Media module init function. Media modules place their hook and filter functions in the init
- * function inside their class. When the core loads media modules, it fires the init function in each
- * media module, attaching the module's functions to the core.
- *
- * @version 0.1.9
- * @since 0.1.9
- */
- public function init(){
- return true;
- }
- /**
- * Specifies the view structure of the module's screens
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return array | mixed
- */
- public function viewStructure(){
- $result = array(
- "site"=>array("type"=>"page", "views"=>array("visitor") ),
- "profile"=>array("type"=>"page","views"=>array("visitor") ),
- "tab"=>array("type"=>"page","views"=>array("visitor") )
- );
- return $result;
- }
-
- /**
- * Processes a media item and returns relevant data to the media item manager
- *
- * @version 0.1.9
- * @since 0.1.9
- *
- * @param mixed $media_object | Media object (file handle or URL) to process
- * @param array $options | Array of options that controls how the module processes the item
- * @param array &$error | Array numeric error code and text error string
- * @return bool/array | False on failure. Media item data array on success.
- */
- public function processItem($media_object, $options, &$error=null){
- return true;
- }
- /**
- * Deletes the master content for a media item. This is implemented in the individual media
- * modules instead of the plugin core so that media modules which host content on 3rd-party
- * servers (Amazon S3, etc) can connect to the remote server's API and delete the item.
- *
- * @version 0.1.9
- * @since 0.1.9
- *
- * @param array $media_item | Full database record of the item being deleted
- * @param array &$error | Error data returned on failure
- * @return bool | False on failure. True on success
- */
- public function deleteItem($media_item, &$error=null){
- return true;
- }
- /**
- * Renders the configuration page for a media module, as seen on the admin
- * "media modules" screen.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | composited HTML block
- */
- public function adminConfigPage(){
- global $bpm;
- require ( dirname( __FILE__ ) . '/admin/loader.php' );
- $current_page = new BPMM_admin_loader( new self() );
-
- }
- /**
- * Renders the configuration page for a media module, as seen on the user's
- * site settings screens.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | composited HTML block
- */
- public function userConfigPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they create a new
- * instance of an media type owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_createMedia(){
- }
- /**
- * Renders the HTML block for an upload page when items are uploaded to an
- * media type owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_uploadItem(){
- }
- /**
- * Renders the HTML block for the page a user sees when they edit an
- * instance of an media type owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_editMedia(){
- }
- /**
- * Renders the HTML block for the page a user sees when they edit an individual
- * media item within an instance of an media type owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_editItem(){
- }
- /**
- * Renders the HTML block for the first page of items a user sees when they
- * view an instance of an media type owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_landingPage(){
- }
- /**
- * Renders the HTML block for for the second and subsequent pages of items a user
- * sees when they view an instance of an media type owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_galleryPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they view an individual
- * item within an media instance owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_singlePage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they sort items within
- * an media instance owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_sortPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they apply user tags to a
- * media item within an media instance owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_userTagPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they apply keyword tags to
- * a media item within an media instance owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_keywordTagPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they add geotagging info to
- * a media item within an media instance owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_geoTagPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they add licensing info to
- * a media item within an media instance owned by the media module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_licenseTagPage(){
- }
- public function register(){
- global $bpm;
- $slug = $this->getSlug();
- $name = $this->getName();
- $php_class = get_class($this);
- $bpm->mediaModules->register($slug, $name, $php_class);
- }
-
- }
- $temp = new BPMM_audioEmbed();
- $temp->register();
- unset($temp);
- ?>