Логин:

Пароль:

Форумы
Общие вопросы
Document Object Model
Обсуждаем конференцию
Web Usability (test)

Общие вопросы

либа

Либа,используемая в примере:
<?
/*
* (c) 2001 Alexey Kulentsov, Otamedia Ltd.
*
* History:
* 29.03.2001 - Started
* 09.04.2001 - pop('tagname') added
* 16.03.2002 - cdata now is conditional
*/
if(!defined('_CLASS_TAG')){
.define('_CLASS_TAG',1);


// Not completed now, only for testing purposes
$body_tags=array('DIV','P','H1','H2','H3','H4','H5','H6','TABLE','FORM','SCRIPT','CENTER','FONT','B','I','U','NOBR','PRE','STRONG','ADDRESS','CODE');

$HTML_dtd=array(

'HTML' =>array('HEAD','BODY','FRAMESET'),
'FRAMESET'=>array('FRAME','FRAMESET'),
'HEAD' =>array('TITLE','SCRIPT'),
'BODY' =>&$body_tags,
'TABLE' =>array('TR','TC'),
'TR' =>array('TD'),
'DIV' =>&$body_tags,
'CENTER' =>&$body_tags,
'TD' =>&$body_tags
);


class tag
{
.var.$tags=array();
.var.$CheckIt=false;

.function tag()
.{
..$arg_list=func_get_args();
..if(count($arg_list))
...$this->push($arg_list);
.}

.function tagname($tag)
.{
..$tagname=explode(' ',$tag);
..return $tagname[0];
.}

.function push_one($tag)
.{
..$tagname=$this->tagname($tag);
..if($this->CheckIt && count($this->tags))
..{ global $HTML_dtd;
...$prev=strtoupper($this->tags[count($this->tags)-1]);
...$allowed=&$HTML_dtd[$prev];
...if(count($allowed))
....if(!in_array(strtoupper($tagname),$allowed))
.....trigger_error("DTD error: $tag not allowed in $prev",E_USER_WARNING);
..}
..array_push($this->tags,$tagname);
..echo "<$tag>";
.}

.function push()
.{.$arg_list=func_get_args();
..foreach($arg_list as $arg)
...if(gettype($arg)=='array')
....foreach($arg as $item)
.....$this->push_one($item);
...else.$this->push_one($arg);..
.}

.function pop_one($ptag=null)
.{
..if(!count($this->tags)) trigger_error('Can\'t pop tag!',E_USER_WARNING);
..$tag=array_pop($this->tags);
..if(isset($ptag) && $tag!=$ptag)
..{.trigger_error("Popped <B>&lt;/$ptag&gt;</B> instead <B>&lt;/$tag&gt;</B>",E_USER_WARNING);
...return false;
..}
..echo "</$tag>";
..return true;
.}
.function pop()
.{.$arg_list=func_get_args();
..if(!count($arg_list))
...$arg_list=array(1);
..foreach($arg_list as $arg)
...switch(gettype($arg)){
...case 'array':
....foreach($arg as $item)
.....$this->pop($item);
....break;
...case 'string':.
....if($arg!='all')
....{.$this->pop_one($arg);
.....break;
....}
....$arg=count($this->tags);
...case 'integer':
....while($arg-- > 0)
.....$this->pop_one();
....break;
...default:
....trigger_error('Incorrect argument type in tag-&gt;pop()',E_USER_ERROR);
...}
.}

}

function SPAN($tag,$text)
{ $tags=new tag($tag);
.echo $text;
.$tags->pop('all');
}

function t($tag,$text)
{.$tags=new tag();
.return '<'.$tag.'>'.$text.'</'.$tags->tagname($tag).'>';
}
function cdata($text,$conditional=false)
{.
.if($conditional && preg_match('/^[^<>&\'"]*$/',$text))
..return $text;

.$text=str_replace("]]>","]]>]]<![CDATA[>",$text);
.return '<![CDATA['.$text.']]>';
}
function to_tag($text)
{.
.$from=" \"\t\\/:#$%^&*()=+-!`'~?<>[],.";
.$retval=strtr($text,$from,str_repeat('_',strlen($from)));
.//echo "\r\n<BR>[$text] >> [$retval]";
.return $retval;
}

function mark_links($s)
{
.$s=ereg_replace("(([hH][tT][tT][pP][sS]{0,1}|[fF][tT][pP])://[a-zA-Z0-9\.=?+%~#:&/_-]+)","]]><link><href>\\1</href><text>\\1</text></link><![CDATA[",$s);
.$s=ereg_replace("([ ]|^)(www\.[a-zA-Z0-9\.=?+%~#:&/_-]+)( |$)","\\1]]><link><href>http://\\2</href><text>\\2</text></link><![CDATA[\\3",$s);
.$s='<![CDATA['.ereg_replace("([_a-zA-Z0-9\.-]+\@[-_a-zA-Z0-9\.]+)","]]><mail_link><href>\\1</href><text>\\1</text></mail_link><![CDATA[",$s).']]>';
.return $s;
}


}

?>
СообщениеАвторДата
Designer23.08.2002 12:52
Leechy23.08.2002 16:56
crimaniak24.08.2002 19:42
MetaWizard24.08.2002 20:36
crimaniak25.08.2002 15:11
MetaWizard25.08.2002 16:49
crimaniak26.08.2002 00:03
гоша26.08.2002 15:15
crimaniak27.08.2002 13:35
MetaWizard23.08.2002 16:51
Designer23.08.2002 18:47
crimaniak24.08.2002 16:12
Designer26.08.2002 17:28
crimaniak27.08.2002 13:12
MetaWizard28.08.2002 17:23
crimaniak29.08.2002 13:55
Dworkin09.01.2003 17:20
Designer29.08.2002 11:55
Pha-pha28.08.2002 18:30
crimaniak27.08.2002 18:22
Designer28.08.2002 13:10
crimaniak29.08.2002 13:45
Designer29.08.2002 16:26
Designer29.08.2002 16:23
crimaniak30.08.2002 20:36
Designer для Crimaniak05.09.2002 15:16
crimaniak09.09.2002 14:20
Designer для Crimaniak10.09.2002 12:07
crimaniak10.09.2002 13:15
Designer для Crimaniak10.09.2002 13:58
crimaniak10.09.2002 20:31
Designer для Crimaniak11.09.2002 11:16
Leechy11.09.2002 12:49
Designer для Crimaniak11.09.2002 17:13
Designer для Crimaniak10.09.2002 13:49
Designer05.09.2002 11:27
crimaniak29.08.2002 13:50
crimaniak29.08.2002 13:48
Designer27.08.2002 14:09
crimaniak27.08.2002 14:58
crimaniak27.08.2002 13:16
crimaniak27.08.2002 13:14
crimaniak27.08.2002 13:13
MetaWizard26.08.2002 18:34
Designer27.08.2002 11:07
Designer27.08.2002 11:03
маринаГость26.04.2003 17:10
Гость александр14.03.2003 12:50
Гость28.12.2002 13:49