Jump to content

  •  

  • Tutorial info Visit support topic

    • Added on: Dec 23 2009 04:19 AM
    • Date Updated: Dec 23 2009 05:30 PM
    • Views: 1630
     


    * * * * *
    3 Ratings

    Auto parse media links

    Posted by Martin on Dec 23 2009 04:19 AM
    With this tutorial applied, all your member will have to do, is post a link to a video supported by the media tag, and it will automatically be parsed as a video.

    Open ./admin/sources/classes/bbcode/core.php
    Find: (Around line 1450)
    //-----------------------------------------
    		// Auto parse URLs (only if this is full sweep)
    		//-----------------------------------------
    Add above
    		/**
    		 * (IM) Auto parse media tags
    		 */
    		  
    		if( !$_code AND $cur_method == 'display' )
    		{
    			$media		= $this->cache->getCache( 'mediatag' );
    			
    			if( is_array($media) AND count($media) )
    			{
    				foreach( $media as $type => $r )
    				{
    					if( preg_match( "#(^|\s|>|\](?<!\[media\]))(" . $r['match'] . "[^,\s\<\[]+)#", $txt, $matches ) )
    					{
    						$txt = preg_replace_callback( "#(^|\s|>|\](?<!\[media\]))(" . $r['match'] . "[^,\s\<\[]+)#", array( $this, '_autoParseMedia' ), $txt );
    					}
    				}
    			}
    		}

    Find:
    	private function _autoParseUrls( $matches )
    	{
    		return $this->parseBbcode( $matches[1] . '[url]' . $matches[2] . '[/url]', 'display', 'url' );
    	}
    Add below
    	
    	/**
    	 * (IM) Auto parse media tags 
    	 * 
    	 * Callback to auto parse media tags
    	 * 
    	 * @access	private
    	 * @param	array		Matches from the regular expression
    	 * @return	string		Converted text
    	 */
    	private function _autoParseMedia( $matches )
    	{
    		return $this->parseBbcode( $matches[1] . '[media]' . $matches[2] . '[/media]', 'display', 'media' );
    	}

    Powered by Tutorials 1.4.1 © 2012, by Michael McCune