readme
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 代码 · 共 497 行 · 第 1/2 页
TXT
497 行
is, we generate files in our cache, and generate <img /> HTML tags thatreferences these files. This is fast, and saves us multiple renderings of thesame image. You should look into these techniques if your tags are graphicallyintensive or otherwise ressource consuming. Also, <img:gtext /> uses a lot ofparameters, and often these are similar across multiple calls of <img:gtext />on the same page. We supply <img:gtextdefault /> as a mechanism to providesensible defaults to subsequent calls. Look into our code to learn how we didthis.The PHP namespace implements <php:define />, which gobbles up its contentsunparsed. In order to do this it uses getLock() and releaseLock() intransformer. If you need code that is read as-is and evaluated later, look intothis. Also, the PHP namespace uses PHP's eval function extensively to generatenamespace classes at run-time. This is not a recommended practice, but probablyinteresting code.2.4.1 XML_Transformer_Namespace_AnchorThe Anchor namespace implements a number of tags that create indirect namedlinks (URNs): The link is specified by name, and the actual link location andtitle are supplied from a database internal to the class. Additionally, a tagthat selects a random link is supplied.The default namespace prefix for this Namespace is "a".2.4.1.1 Link databaseThe link database is maintained internally as an array, _anchorDatabase and isaccessible through the setDatabase($db) and $db = getDatabase() accessormethods. $a = new XML_Transformer_Namespace_Anchor(); $t = new XML_Transformer(); $t->overloadNamespace('a', $a); $a->setDatabase( array( 'php' => array( 'href' => 'http://www.php.net', 'title' => 'PHP Homepage' ), 'pear' => array( 'href' => 'http://pear.php.net', 'title' => 'PEAR Homepage' ) ) );Additionally, items may be added to or dropped from the database using theaddItem() and dropItem() methods. Also, individual items can be queried withgetItem(). $a->addItem( 'dclpfaq', array( 'href' => 'http://www.dclp-faq.de', 'title' => 'de.comp.lang.php FAQ Homepage' ) ); $dclpfaq = $a->getItem('dclpfaq'); echo $dclpfaq['href']; $a->dropItem('dclpfaq');Note that neither database nor the tags place any restrictions on the number orkind of attributes ("href", "title", ...) stored in the database. All attributeswill be reproduced "as is" on the generated links.2.4.1.2 The <a:iref> tagThe <a:iref iref="name" /> container will look the given name up in the databaseand produce a HTML <a /> container. The attributes find in the link databasewill be produced literally as attributes to the <a /> container and the contentsof the <a:iref /> will become the contents of the <a /> container.Example:<a:iref iref="php">The PHP Homepage</a:iref>Result:<a href="http://www.php.net" title="PHP Homepage">The PHPHomepage</a>2.4.1.3 The <a:random> tagThe <a:random /> container will select a random name from the database and linkto it. The contents of the <a:random /> become the contents of the generated<a /> container.Example:<a:random>A random link</a:random>Result:<a href="http://www.php.net" title="PHP Homepage">A random link</a>2.4.1.4 The <a:link> tagThe link tag will add a link to the database, and vanishes (generates nooutput). The name attribute to link will define the link name, the otherattributes are copied into the database literally.Example:<a:link name="php" href="http://www.php.net" title="PHP Homepage" />Result:The link is added to the database. No output is being generated.2.4.2 XML_Transformer_Namespace_DocBook* TODO (sb)2.4.3 XML_Transformer_Namespace_ImageThe Image namespace implements a number of tags that are loosely related toimages. At the moment there is a tag that autogenerates height/width attributesand another tag that turns its content text into a PNG with that text.The default namespace prefix for this namespace is "img".2.4.3.1 The <img> tag.This tag will generate a <img /> tag with the original attributes, and will addwidth and height attributes if possible.Example:<img:img src="somepng.png" alt="blah" />Result:<img alt="blah" height="168" src="somepng.png" width="320" />2.4.3.2 The <gtext> tagGtext is short for graphical text. The tag will take its content and turn itinto a single PNG or a series of PNGs using ImageTTFText() internally.Gtext takes a very large number of attributes. All of them can be specified asdefaults with <img:gtextdefault /> (see below) and individually overridden.Limitations:Gtext requires a directory called "/cache/gtext" below DocumentRoot that iswriteable by the webserver. Also, Fonts are looked for in/usr/X11R6/lib/X11/fonts/truetype. Currently there is no API to override this.Attributes:- split Split is either "none", "word" or "char". If it is "none", the complete content of a gtext is set as a single image. If it is "word", each word of the content is set as a separate image. This does not look as good as a single image, but can be word wrapped. If it is "char", each character is rendered as a single image. This loads very fast (multiple occurences of the same character are mapped onto the same file), but does not look right.- font Name of the TTF font to use. If an absolute pathname is supplied, that font is being used. Otherwise /usr/X11R6/lib/X11/fonts/truetype/ is prepended to the font name and that file is tried.- fontsize What size to render the font in (TTF points).- alt By default, each generated image is created with the text on the image as alt Tag. This can be overridden by specifying an alt tag (not recommended). Note that XML attributes may not contain tags. Thus, all markup is being stripped from the automatically generated alt tag in order to ensure well- formed HTML.- bgcolor, fgcolor The generated image is initially filled with bgcolor. This color is then set to transparent (unless prohibited, see below). After that, text is rendered in fgcolor into this image.- antialias The rendered text is by default generated with antialiasing. If you do not want the text to be antialiased, set the antialias attribute to "no".- transparency The background color is by default set to transparent. If you do not want the bgcolor to be set transparent, set the transparency attribute to "no".- cacheable By default, the generated image is stored in the gtext cache. After that, subsequent renderings of that image are not done. Instead the cached image is referenced. If you set the cacheable attribute to "no", the image is recreated on each <img:gtext /> call. This is recommended during development.- spacing <img:gtext /> tries to create the generated PNG as small as possible. If you specify a spacing attribute, a transparent border of x pixels is added around all four borders of the generated image.- border Additionally, if you specify a border, an x pixel border is added around the text and the spacing. Unlike spacing the border is painted in bordercolor.- bordercolor The color to paint the border in is specified using the bordercolor attribute.Example: <img:gtextdefault bgcolor="888888" fgcolor="#000000" font="arial.ttf" fontsize="33" border="2" spacing="2" split="" cacheable="no"/> <img:gtext>Antialias</img:gtext><br/> <img:gtext antialias="no">No Antialias</img:gtext><br/> <img:gtext>OoAaMmXxGgQqpP
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?