1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-03 06:55:03 +03:00

доработка Jevix на предмет обязательных параметров + обязательный параметр wmode=opaque для embed

This commit is contained in:
Mzhelskiy Maxim 2009-04-04 11:38:30 +00:00
parent e735f09678
commit 0faa2c670d
2 changed files with 1227 additions and 1218 deletions

View file

@ -7,9 +7,16 @@
* http://code.google.com/p/jevix/
*
* @author ur001 <ur001ur001@gmail.com>, http://ur001.habrahabr.ru
* @version 1.00
* @version 1.01
*
* История версий:
* 1.01
* + cfgSetAutoReplace теперь регистронезависимый
* + Возможность указать через cfgSetTagIsEmpty теги с пустым содержанием, которые не будут адалены парсером (rus.engine)
* + фикс бага удаления контента тега при разном регистре открывающего и закрывающего тегов (rus.engine)
* + Исправлено поведение парсера при установке правила sfgParamsAutoAdd(). Теперь
* параметр устанавливается только в том случае, если его вообще нет в
* обрабатываемом тексте. Если есть - оставляется оригинальное значение. (deadyaga)
* 1.00
* + Исправлен баг с закрывающимися тегами приводящий к созданию непарного тега рушащего вёрстку
* 1.00 RC2
@ -278,9 +285,9 @@ class Jevix{
}
/**
* CONFIGURATION: Adding autoadd attributes and their values to tag
* CONFIGURATION: Adding autoadd attributes and their values to tag. If the 'rewrite' set as true, the attribute value will be replaced
* @param string $tag tag
* @param string|array $params array of pairs attributeName => attributeValue
* @param string|array $params array of pairs array('name'=>attributeName, 'value'=>attributeValue, 'rewrite'=>true|false)
*/
function cfgSetTagParamsAutoAdd($tag, $params){
if(!isset($this->tagsRules[$tag])) throw new Exception("Tag $tag is missing in allowed tags list");
@ -288,8 +295,8 @@ class Jevix{
if(!isset($this->tagsRules[$tag][self::TR_PARAM_AUTO_ADD])) {
$this->tagsRules[$tag][self::TR_PARAM_AUTO_ADD] = array();
}
foreach($params as $param => $value){
$this->tagsRules[$tag][self::TR_PARAM_AUTO_ADD][$param] = $value;
foreach($params as $aParamValue){
$this->tagsRules[$tag][self::TR_PARAM_AUTO_ADD][$aParamValue['name']] = array('value'=>$aParamValue['value'],'rewrite'=>$aParamValue['rewrite']);
}
}
@ -357,7 +364,7 @@ class Jevix{
if(!empty($this->autoReplace)){
$this->text = str_replace($this->autoReplace['from'], $this->autoReplace['to'], $this->text);
$this->text = str_ireplace($this->autoReplace['from'], $this->autoReplace['to'], $this->text);
}
$this->textBuf = $this->strToArray($this->text);
$this->textLen = count($this->textBuf);
@ -904,10 +911,10 @@ class Jevix{
// Автодобавляемые параметры
if(!empty($tagRules[self::TR_PARAM_AUTO_ADD])){
foreach($tagRules[self::TR_PARAM_AUTO_ADD] as $name => $value) {
foreach($tagRules[self::TR_PARAM_AUTO_ADD] as $name => $aValue) {
// If there isn't such attribute - setup it
if(!array_key_exists($name, $resParams)) {
$resParams[$name] = $value;
if(!array_key_exists($name, $resParams) or ($aValue['rewrite'] and $resParams[$name] != $aValue['value'])) {
$resParams[$name] = $aValue['value'];
}
}
}

View file

@ -59,7 +59,7 @@ class LsText extends Module {
$this->oJevix->cfgAllowTagParams('cut', array('name'));
$this->oJevix->cfgAllowTagParams('object', array('width' => '#int', 'height' => '#int', 'data' => '#link'));
$this->oJevix->cfgAllowTagParams('param', array('name' => '#text', 'value' => '#text'));
$this->oJevix->cfgAllowTagParams('embed', array('src' => '#image', 'type' => '#text','allowscriptaccess' => '#text', 'allowfullscreen' => '#text','width' => '#int', 'height' => '#int', 'flashvars'=> '#text'));
$this->oJevix->cfgAllowTagParams('embed', array('src' => '#image', 'type' => '#text','allowscriptaccess' => '#text', 'allowfullscreen' => '#text','width' => '#int', 'height' => '#int', 'flashvars'=> '#text', 'wmode'=> '#text'));
// Параметры тегов являющиеся обязательными
$this->oJevix->cfgSetTagParamsRequired('img', 'src');
$this->oJevix->cfgSetTagParamsRequired('a', 'href');
@ -72,6 +72,8 @@ class LsText extends Module {
$this->oJevix->cfgSetTagChilds('object', 'embed', false, false);
// Если нужно оставлять пустые не короткие теги
$this->oJevix->cfgSetTagIsEmpty(array('param','embed'));
// Теги с обязательными параметрами
$this->oJevix->cfgSetTagParamsAutoAdd('embed',array(array('name'=>'wmode','value'=>'opaque','rewrite'=>true)));
// Отключение авто-добавления <br>
//$this->oJevix->cfgSetAutoBrMode(false);
// Автозамена