• 14-12-2013, 16:47:25
    #1
    Merhaba,

    Bos vaktim'de yazmis oldugum bbcode sinifimi sizlerle paylasmaya karar verdim.
    Suanda 5 video sitesi destekliyor ve daha fazla eklenebilir.

    Youtube kullanimi :
    [youtube]H7rhMqTQ4WI[/youtube]
    Dailymotion kullanimi :
    [dailymotion]x1hksy[/dailymotion]
    Vimeo kullanimi :
    [vimeo]24386643[/vimeo]
    Izlesene kullanimi :
    [izlesene]7139646[/izlesene]
    Vidivodo kullanimi :
    [vidivodo]BFRFRlpBWVAT[/vidivodo]
    Sinif & Örnek Kullanimi :

    /**
    Coded by Kingofseo
    Date : 14.12.2013
    **/
    
    class bbcode{
    protected $param;
    
    /**
    Build the __construct()
    @return null;
    **/
    
    public function __construct($param){
    $this->param=$param;
    return null;
    }
    
    /**
    Build the function apply_bb()
    @return $getir;
    **/
    
    public function apply_bb(){
    Switch(true){
    Case (strstr($this->param,"[youtube]") && strstr($this->param,"[/youtube]")):
    $getir=preg_replace('/\[youtube](.*?)\[\/youtube\]/i','<iframe width="640" height="390" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
    break;
    Case (strstr($this->param,"[dailymotion]") && strstr($this->param,"[/dailymotion]")):
    $getir=preg_replace('/\[dailymotion](.*?)\[\/dailymotion\]/i','<iframe width="640" height="390" src="http://www.dailymotion.com/embed/video/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
    break;
    Case (strstr($this->param,"[vimeo]") && strstr($this->param,"[/vimeo]")):
    $getir=preg_replace('/\[vimeo](.*?)\[\/vimeo\]/i','<iframe width="640" height="390" src="//player.vimeo.com/video/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
    break;
    Case (strstr($this->param,"[izlesene]") && strstr($this->param,"[/izlesene]")):
    $getir=preg_replace('/\[izlesene](.*?)\[\/izlesene\]/i','<iframe width="640" height="390" src="http://www.izlesene.com/embedplayer/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
    break;
    Case (strstr($this->param,"[vidivodo]") && strstr($this->param,"[/vidivodo]")):
    $getir=preg_replace('/\[vidivodo](.*?)\[\/vidivodo\]/i','<embed src="http://www.vidivodo.com/VideoPlayerShare.swf?u=$1" type="application/x-shockwave-flash" wmode="window" bgcolor="#090909" width="640" height="390" allowScriptAccess="always" allowfullscreen="true" ></embed>',$this->param);
    break;
    Default:
    return false;
    break;
    }
    return $getir;
    }
    }
    
    $bbcode=new bbcode("[vidivodo]BFRFRlpBWVAT[/vidivodo]");
    echo $bbcode->apply_bb();
    Form Kullanimi :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    	<title>Kingofseo BBcode uygulamasi</title>
    </head>
    <body>
    <?php
    if($_POST){
    $bbcode=trim($_POST["bbcode"]);
    if(!empty($bbcode)){
    $bbcode=new bbcode($bbcode);
    if(false===$bbcode->apply_bb()) echo "<b> Site bulunamadi ! </b>";
    echo $bbcode->apply_bb();
    }else{
    echo "<b>  Lütfen BBkodunu giriniz ! </b>";
    }
    }
    ?>
    
    <form action="class.bbcode.php" method="POST">
    <b> BBkodu (örnek : [vidivodo]BFRFRlpBWVAT[/vidivodo] ) </b> : <input type="text" name="bbcode" <?php echo !empty($_POST["bbcode"]) ? 'value="'.trim($_POST["bbcode"]).'"' : null;?>>
    <input type="submit" value="Gönder !">
    </form>
    
    	
    </body>
    </html>
    Güle Güle kullanin ve yararli olmasi dilegiyle.
  • 16-12-2013, 18:42:23
    #2
    Teşekkürler ellerine sağlık.

    eğer faydalı olucak ise ben şu şekilde bir uygulama yazmıştım. sınıfını geliştirirken belki minik bir mantık yardımı olabilir.


    Herbirini ayrı ayrı bbcode halinde kullanmak yerine

    [video]http://videourladresi.com[/video]
    tek video tagı kullanıp

    videoOynat($url){
         $en = 320;
         $boy = 180;
    if(stripos($url[1],"youtube"){
         $video = preg_replace(
                   '#http://(?:www\.)?youtube.com/(watch\?v=|v/)(.*?)#i', 
                   'http://www.youtube.com/embed/\3', 
                   $url[1]
              );
         return '<iframe width="'.$en.'" height="'.180.'" src="'.$video.'" frameborder="0" allowfullscreen></iframe>';   
    }elseif(stripos($url[1],"dailymo"){
    //dailymotion kodu
    }
    }

    $degisken = '<div class="video">
    Bu kısımda konuyu anlatan bir metin bulunur. Bu kısımda konuyu anlatan bir metin bulunur.  
    [video]http://www.youtube.com/watch?v=QQQ7kva3LXc&feature=g-crec[/video]
    videodan soraki kalan yazılar
    </div>';
    
    
    $sablon = '#\[video\](.*?)\[\/video\]#is';  
    echo preg_replace_callback($sablon, 'videoOynat', $degisken);
  • 17-12-2013, 18:19:25
    #3
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Arkadaşlar bende bi' tane yapayım dedim. Benimkisi biraz daha basit oldu.
    İlgili pakete buradan bakabilirsiniz. (GitHub adresi vs. tüm bilgiler yer alıyor.)

    Kullanımı için;

    composer.json'a;
    {
    	"require": {
    		"imsaintx/bbcode": "dev-master",
    		"zendframework/zend-stdlib": "2.3.*@dev",
    		"zendframework/zend-json": "2.3.*@dev"
    	}
    }
    test dosyası;
    <?php
    	
    	require( "./vendor/autoload.php" );
    	
    	use Bbcode\Bbcode;
    	
    	Bbcode::addDefinition("youtube", "\[youtube\](.*)\[\/youtube\]", "<iframe src=\"http://www.youtube.com/embed/$1\" width=\"640\" height=\"480\" frameborder=\"0\"></iframe>")
    		  ->putHtml("<p>[youtube]ARypk5P6tPY[/youtube]</p>")
    		  ->parse();
    	
    	echo Bbcode::getOutput();
  • 17-12-2013, 19:30:46
    #4
    saintx adlı üyeden alıntı: mesajı görüntüle
    Arkadaşlar bende bi' tane yapayım dedim. Benimkisi biraz daha basit oldu.
    İlgili pakete buradan bakabilirsiniz. (GitHub adresi vs. tüm bilgiler yer alıyor.)

    Kullanımı için;

    composer.json'a;
    {
    	"require": {
    		"imsaintx/bbcode": "dev-master",
    		"zendframework/zend-stdlib": "2.3.*@dev",
    		"zendframework/zend-json": "2.3.*@dev"
    	}
    }
    test dosyası;
    <?php
    	
    	require( "./vendor/autoload.php" );
    	
    	use Bbcode\Bbcode;
    	
    	Bbcode::addDefinition("youtube", "\[youtube\](.*)\[\/youtube\]", "<iframe src=\"http://www.youtube.com/embed/$1\" width=\"640\" height=\"480\" frameborder=\"0\"></iframe>")
    		  ->putHtml("<p>[youtube]ARypk5P6tPY[/youtube]</p>")
    		  ->parse();
    	
    	echo Bbcode::getOutput();
    Basit ama yararli olmus ellerine saglik

    --R10.NET; Flood Engellendi -->-> Yeni yazılan mesaj 20:30:46 -->-> Daha önceki mesaj 20:29:22 --

    MaviTm adlı üyeden alıntı: mesajı görüntüle
    Teşekkürler ellerine sağlık.

    eğer faydalı olucak ise ben şu şekilde bir uygulama yazmıştım. sınıfını geliştirirken belki minik bir mantık yardımı olabilir.


    Herbirini ayrı ayrı bbcode halinde kullanmak yerine

    [video]http://videourladresi.com[/video]
    tek video tagı kullanıp

    videoOynat($url){
         $en = 320;
         $boy = 180;
    if(stripos($url[1],"youtube"){
         $video = preg_replace(
                   '#http://(?:www\.)?youtube.com/(watch\?v=|v/)(.*?)#i', 
                   'http://www.youtube.com/embed/\3', 
                   $url[1]
              );
         return '<iframe width="'.$en.'" height="'.180.'" src="'.$video.'" frameborder="0" allowfullscreen></iframe>';   
    }elseif(stripos($url[1],"dailymo"){
    //dailymotion kodu
    }
    }

    $degisken = '<div class="video">
    Bu kısımda konuyu anlatan bir metin bulunur. Bu kısımda konuyu anlatan bir metin bulunur.  
    [video]http://www.youtube.com/watch?v=QQQ7kva3LXc&feature=g-crec[/video]
    videodan soraki kalan yazılar
    </div>';
    
    
    $sablon = '#\[video\](.*?)\[\/video\]#is';  
    echo preg_replace_callback($sablon, 'videoOynat', $degisken);
    Böylede olabilir ellerine saglik.