Kak да вкараме YouTube видео в THtmlArea на Prado?
Имах странен проблем с прадовския компонент THtmlArea свързан с вкарването на видео не само от YouTube, а и от другите алтернативни сайтове. Изглежда компонента е програмиран така, че няма как да го настроиш да позволява object и embed тагове. Все пак, ако се използва Text атрибута всичко е наред. А ако използвате SafeText атрибута ще имате проблема, който току що описах. Това, което аз направих беше да разширя компонента THtmlArea и създадох мой, който преодолява това ограничение. Ето го и него:
<?php
/**
* MTHtmlArea class file.
*
* @author Georgi Budinov <georgi[at]budinov[dot]com>
* @link http://georgi.budinov.com/
*
* MTHtmlArea class
*
* Enables the embed and object tag in order post embeded videos from YouTube for
* example still using the safe text property
*/
//Includes THtmlArea class
Prado::using('System.Web.UI.WebControls.THtmlArea');
class MTHtmlArea extends THtmlArea
{
public function __construct()
{
parent::__construct();
$ind = array_search('object', $this->SafeTextParser->deleteTags);
if($ind >= 0)
{
unset($this->SafeTextParser->deleteTags[$ind]);
}
// remove the embed tag from the list if it is there
$ind = array_search('embed', $this->SafeTextParser->deleteTags);
if($ind >= 0)
{
unset($this->SafeTextParser->deleteTags[$ind]);
}
//reset the indexes
$this->SafeTextParser->deleteTags = array_values($this->SafeTextParser->deleteTags);
}
}
?>
Може да използвате компонента по следния начин:
<com:MTHtmlArea ID="Test"> <prop:Options> extended_valid_elements: "object[width|height],param[name|value],embed[src|type|allowscriptaccess|allowfullscreen|width|height]" </prop:Options> </com:MTHtmlArea>
Трябва да добавите extended_valid_elements опцията за да позволите на tinymce да приема въпросните тагове.
Ако използвате някоя от по-ранните версии на Prado това не е задължително.
Прочети статията на: English











English
Bulgarian 

Все още няма коментари.