/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
require_once('classes/lib/external/Jevix/jevix.class.php');
require_once('classes/lib/external/geshi/geshi.php');
/**
* Модуль обработки текста на основе типографа Jevix
*
*/
class Text extends Module {
/**
* Объект типографа
*
* @var Jevix
*/
protected $oJevix;
/**
* Инициализация модуля
*
*/
public function Init() {
/**
* Создаем объект типографа и запускаем его конфигурацию
*/
$this->oJevix = new Jevix();
$this->JevixConfig();
}
/**
* Конфигурирует типограф
*
*/
protected function JevixConfig() {
// Разрешённые теги
$this->oJevix->cfgAllowTags(array('cut','a', 'img', 'i', 'b', 'u', 's', 'video', 'em', 'strong', 'nobr', 'li', 'ol', 'ul', 'sup', 'abbr', 'sub', 'acronym', 'h4', 'h5', 'h6', 'br', 'hr', 'pre', 'code'));
// Коротие теги типа
$this->oJevix->cfgSetTagShort(array('br','img', 'hr', 'cut'));
// Преформатированные теги
$this->oJevix->cfgSetTagPreformatted(array('pre','code'));
// Разрешённые параметры тегов
$this->oJevix->cfgAllowTagParams('img', array('src', 'alt', 'title', 'align'));
$this->oJevix->cfgAllowTagParams('a', array('title', 'href'));
$this->oJevix->cfgAllowTagParams('cut', array('name'));
// Параметры тегов являющиеся обязательными
$this->oJevix->cfgSetTagParamsRequired('img', 'src');
$this->oJevix->cfgSetTagParamsRequired('a', 'href');
// Теги которые необходимо вырезать из текста вместе с контентом
$this->oJevix->cfgSetTagCutWithContent(array('script', 'object', 'iframe', 'style'));
// Вложенные теги
$this->oJevix->cfgSetTagChilds('ul', array('li'), false, true);
$this->oJevix->cfgSetTagChilds('ol', array('li'), false, true);
// Отключение авто-добавления
//$this->oJevix->cfgSetAutoBrMode(false);
// Автозамена
$this->oJevix->cfgSetAutoReplace(array('+/-', '(c)', '(r)', '(C)', '(R)'), array('±', '©', '®', '©', '®'));
//$this->oJevix->cfgSetXHTMLMode(false);
}
/**
* Парсинг текста с помощью Jevix
*
* @param string $sText
* @param array $aError
* @return string
*/
public function JevixParser($sText,&$aError=null) {
$sResult=$this->oJevix->parse($sText,$aError);
return $sResult;
}
/**
* Парсинг текста на предмет видео
*
* @param string $sText
* @return string
*/
public function VideoParser($sText) {
/**
* youtube.com
*/
$sResult = preg_replace('/