2.2 Text对象的实现
Text对象是我们定义的第1个元素对象。它包含的属性和函数如下表所示:
|
属性名称 |
含义 |
|
$text |
文本内容 |
|
$attribute |
文本格式属性 |
|
$br_count |
文本后空行数目 |
|
方法名(函数) |
功能 |
|
My_Text |
自构函数,对象创建时被自动调用 |
|
set_br_count |
设置空行数目 |
|
My_Type |
返回对象类别(I_AM_TEXT) |
|
Make_Element |
产生与Text对象相关的代码 |
在各函数中,Make_Element函数将被Deck对象使用,My_Type函数也将被调用以供Deck对象确定本对象的类型。
Make_Element对象的实现比较复杂,其相关代码如下所示。在代码中,首先产生有关Text格式的代码,然后再产生Text内容,最后产生代码结尾。
|
//创建Text部分代码 function Make_Element($deck) { if ($this->attribute & TEXT_BOLD) echo "<b>\n";
if ($this->attribute & TEXT_UNDERLINE) echo "<u>\n";
if ($this->attribute & TEXT_ITALIC) echo "<i>\n";
if ($this->attribute & TEXT_BIG) echo "<big>\n"; if ($this->attribute & TEXT_SMALL) echo "<small>\n";
if ($this->text) printf("%s\n", convert_character($this->text));
if ($this->attribute & TEXT_SMALL) echo "</small>\n";
if ($this->attribute & TEXT_BIG) echo "</big>\n";
if ($this->attribute & TEXT_ITALIC) echo "</i>\n";
if ($this->attribute & TEXT_UNDERLINE) echo "</u>\n";
if ($this->attribute & TEXT_BOLD) echo "</b>\n";
$br_command = "<br/>\n"; for ($i=0; $i<$this->br_count; $i++) echo $br_command; } |
2.3 Image对象的实现
Image对象代表了图象元素,其包含的属性和方法如下表所示:
|
属性名称 |
含义 |
|
$wbmp_url |
图片地址 |
|
$alt_text |
图片文本描述(当图片无法显示时则显示文本) |
|
$br_count |
图片后空行数目 |
|
方法名(函数) |
含义 |
|
My_Image |
自构函数,对象创建时被自动调用 |
|
set_br_count |
设置空行数目 |
|
My_Type |
返回对象类别(I_AM_IMAGE) |
|
Make_Element |
产生与Image对象相关的代码 |
本代码定义了PHP库,用于创建WAP页面
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] 下一页