跳转到内容

Phalcon html

注意

所有类都以前缀命名Phalcon

Html\Attributes

GitHub上的源码

  • 命名空间

    • Phalcon\Html
  • 使用

    • Phalcon\Html\Attributes\RenderInterface
    • Phalcon\Support\Collection
  • 继承

    Collection

  • 实现

    • RenderInterface

该类有助于处理 HTML 属性

方法

public function __toString(): string;
render 方法的别名

public function render(): string;
将属性渲染为 HTML 属性

protected function renderAttributes( array $attributes ): string;
@todo 当我们重构表单时移除该类。可能直接删除此类?将其放入 traits 中

Html\Attributes\AttributesInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Attributes
  • 使用

    • Phalcon\Html\Attributes
  • 继承

  • 实现

  • Phalcon\Html\Attributes\AttributesInterface *

  • 接口 Phalcon\Html\Attributes\AttributesInterface */

方法

public function getAttributes(): Attributes;
获取属性

public function setAttributes( Attributes $attributes ): AttributesInterface;
设置属性

Html\Attributes\RenderInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Attributes
  • 使用

  • 继承

  • 实现

  • Phalcon\Html\Attributes\RenderInterface *

  • 接口 Phalcon\Html\Attributes\RenderInterface */

方法

public function render(): string;
生成字符串表示

Html\Breadcrumbs

GitHub上的源码

  • 命名空间

    • Phalcon\Html
  • 使用

    • Phalcon\Di\DiInterface
  • 继承

  • 实现

Phalcon\Html\Breadcrumbs

此组件提供了一种简便的方式来为您的应用程序创建面包屑导航。在调用时生成的 HTML 为:render()将每个面包屑包含在<dt>标签中,而整个字符串则包含在<dl>标签中。

@deprecated 将在未来的版本中移除,请使用 {@see Phalcon\Html\Helper\Breadcrumbs} 替代。

属性

/**
 * Keeps all the breadcrumbs
 *
 * @var array
 */
private $elements;

/**
 * Crumb separator
 *
 * @var string
 */
private $separator =  / ;

/**
 * The HTML template to use to render the breadcrumbs.
 *
 * @var string
 */
private $template = <dt><a href=\"%link%\">%label%</a></dt>;

方法

public function add( string $label, string $link = string ): Breadcrumbs;
添加一个新的面包屑。

// Adding a crumb with a link
$breadcrumbs->add("Home", "/");

// Adding a crumb without a link (normally the last one)
$breadcrumbs->add("Users");

public function clear(): void;
清除所有面包屑。

$breadcrumbs->clear()

public function getSeparator(): string;
面包屑分隔符

public function remove( string $link ): void;
按 URL 删除面包屑。

$breadcrumbs->remove("/admin/user/create");

// remove a crumb without an url (last link)
$breadcrumbs->remove();

public function render(): string;
基于之前设置的模板渲染并输出面包屑。

echo $breadcrumbs->render();
public function setSeparator( string $separator ): Breadcrumbs;

public function toArray(): array;
返回内部面包屑数组

Html\Escaper

GitHub上的源码

  • 命名空间

    • Phalcon\Html
  • 使用

    • Phalcon\Html\Escaper\EscaperInterface
  • 继承

  • 实现

    • EscaperInterface

Phalcon\Html\Escaper

对不同种类的文本进行转义以确保其安全。通过使用此组件,您可以防止 XSS 攻击。

此组件仅适用于 UTF-8 编码。PREG 扩展需要编译支持 UTF-8。

$escaper = new \Phalcon\Html\Escaper();

$escaped = $escaper->escapeCss("font-family: <Verdana>");

echo $escaped; // font\2D family\3A \20 \3C Verdana\3E

属性

/**
 * @var bool
 */
protected $doubleEncode = true;

/**
 * @var string
 */
protected $encoding = utf-8;

/**
 * ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
 *
 * @var int
 */
protected $flags = 11;

方法

public function attributes( mixed $input ): string;
转义 HTML 属性字符串或数组

如果输入是一个数组,键是属性名,值是属性值。如果某个值为布尔值 (true/false),则属性将没有值:['disabled' => true]-> `'disabled``

结果字符串中的属性对将以空格分隔。

public function css( string $input ): string;
通过将非字母数字字符替换为其十六进制转义表示来转义 CSS 字符串

final public function detectEncoding( string $input ): string | null;
检测字符串的字符编码,以便由编码器处理。对于 mb_detect_encoding() 无法检测到的 chr(172) 和 chr(128) 到 chr(159) 进行特殊处理。

public function escapeCss( string $input ): string;
通过将非字母数字字符替换为其十六进制转义表示来转义 CSS 字符串

public function escapeHtml( string $input = null ): string;
转义 HTML 字符串。内部使用 htmlspecialchars

public function escapeHtmlAttr( string $input = null ): string;
转义 HTML 属性字符串

public function escapeJs( string $input ): string;
通过将非字母数字字符替换为其十六进制转义表示来转义 JavaScript 字符串

public function escapeUrl( string $input ): string;
转义 URL。内部使用 rawurlencode

public function getEncoding(): string;
public function getFlags(): int;

public function html( string $input = null ): string;
转义 HTML 字符串。内部使用 htmlspecialchars

public function js( string $input ): string;
转义 javascript 字符串,通过将非字母数字字符替换为其十六进制转义表示

final public function normalizeEncoding( string $input ): string;
工具方法,用于将字符串的编码规范化为 UTF-32。

public function setDoubleEncode( bool $doubleEncode ): Escaper;
设置转义器使用的 double_encode 值

$escaper->setDoubleEncode(false);

public function setEncoding( string $encoding ): EscaperInterface;
设置转义器使用的编码

$escaper->setEncoding("utf-8");

public function setFlags( int $flags ): EscaperInterface;
设置 htmlspecialchars 的 HTML 引号类型

$escaper->setFlags(ENT_XHTML);

public function setHtmlQuoteType( int $flags ): EscaperInterface;
设置 htmlspecialchars 的 HTML 引号类型

$escaper->setHtmlQuoteType(ENT_XHTML);

public function url( string $input ): string;
转义 URL。内部使用 rawurlencode

protected function phpHtmlSpecialChars( string $input ): string;
测试用代理方法

Html\Escaper\EscaperInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Escaper
  • 使用

  • 继承

  • 实现

Phalcon\Html\Escaper 的接口定义

方法

public function attributes( string $input ): string;
转义 HTML 属性字符串

public function css( string $input ): string;
通过将非字母数字字符替换为其十六进制表示来转义 CSS 字符串

public function getEncoding(): string;
返回转义器使用的内部编码

public function html( string $input ): string;
转义 HTML 字符串

public function js( string $input ): string;
通过将非字母数字字符替换为其十六进制表示来转义 JavaScript 字符串

public function setEncoding( string $encoding ): EscaperInterface;
设置转义器使用的编码

public function setFlags( int $flags ): EscaperInterface;
设置 htmlspecialchars 的 HTML 引号类型

public function url( string $input ): string;
转义 URL。内部使用 rawurlencode

Html\Escaper\Exception

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Escaper
  • 使用

  • 继承

    \Exception

  • 实现

Phalcon\Html\Escaper 中抛出的异常会使用此类

Html\EscaperFactory

GitHub上的源码

  • 命名空间

    • Phalcon\Html
  • 使用

  • 继承

  • 实现

EscaperFactory 类

方法

public function newInstance(): Escaper;
创建一个对象的新实例

Html\Exception

GitHub上的源码

  • 命名空间

    • Phalcon\Html
  • 使用

  • 继承

    \Exception

  • 实现

Phalcon\Html\Tag\Exception

Phalcon\Html\Tag 中抛出的异常将使用此类

Html\Helper\AbstractHelperAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Escaper\EscaperInterface
    • Phalcon\Html\Exception
  • 继承

  • 实现

@property string $delimiter @property EscaperInterface $escaper @property string $indent @property int $indentLevel

属性

/**
 * @var string
 */
protected $delimiter = ;

/**
 * @var EscaperInterface
 */
protected $escaper;

/**
 * @var string
 */
protected $indent =     ;

/**
 * @var int
 */
protected $indentLevel = 1;

方法

public function __construct( EscaperInterface $escaper );
抽象帮助器构造函数。

protected function close( string $tag, bool $raw = bool ): string;
生成一个闭合标签

protected function indent(): string;
按照 indentLevel 复制缩进 x 次

protected function orderAttributes( array $overrides, array $attributes ): array;
保持所有属性排序 - 始终保持相同的顺序

protected function renderArrayElements( array $elements, string $delimiter ): string;
遍历数组并调用第一个元素中定义的方法,第二个元素作为参数,返回结果字符串

protected function renderAttributes( array $attributes ): string;
渲染所有属性

protected function renderElement( string $tag, array $attributes = [] ): string;
渲染一个元素

protected function renderFullElement( string $tag, string $text, array $attributes = [], bool $raw = bool ): string;
渲染一个元素

protected function renderTag( string $tag, array $attributes = [], string $close = string ): string;
渲染一个标签

protected function selfClose( string $tag, array $attributes = [] ): string;
生成自闭合标签,例如:

Html\Helper\AbstractListAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 AbstractList

属性

/**
 * @var array
 */
protected $attributes;

/**
 * @var string
 */
protected $elementTag = li;

/**
 * @var array
 */
protected $store;

方法

public function __invoke( string $indent = string, string $delimiter = null, array $attributes = [] ): AbstractList;

public function __toString();
生成并返回列表的 HTML。

abstract protected function getTag(): string;
返回标签名称。

Html\Helper\AbstractSeriesAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

  • 继承

    AbstractHelper

  • 实现

@property array $attributes @property array $store

属性

/**
 * @var array
 */
protected $attributes;

/**
 * @var array
 */
protected $store;

方法

public function __invoke( string $indent = string, string $delimiter = null ): AbstractSeries;

public function __toString();
生成并返回列表的 HTML。

public function reset(): AbstractSeries;
重置内部存储。

abstract protected function getTag(): string;
返回标签名称。

Html\Helper\Anchor

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Anchor

方法

public function __invoke( string $href, string $text, array $attributes = [], bool $raw = bool ): string;
生成一个标签

protected function processAttributes( string $href, array $attributes ): array;

Html\Helper\Base

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Base

方法

public function __invoke( string $href = null, array $attributes = [] ): string;
生成一个<base/> tag.

Html\Helper\Body

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Body

方法

public function __invoke( array $attributes = [] ): string;
生成一个<body> tag.

Html\Helper\Breadcrumbs

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Escaper\EscaperInterface
    • Phalcon\Support\Helper\Str\Interpolate
  • 继承

    AbstractHelper

  • 实现

此组件提供了一种简便的方式来为您的应用程序创建面包屑导航。在调用时生成的 HTML 为:render()将每个面包屑包含在<li>标签中,而整个字符串则包含在<nav><ol>标签中。

@phpstan-type TTemplate = array{ main: string, line: string, last: string, } @phpstan-type TElement = array{ attributes: array属性:icon(图标)、link(链接)、text(文本)。

属性

/**
 * @var array<string, string>
 */
private $attributes;

/**
 * Keeps all the breadcrumbs.
 *
 * @var array<int, TElement>
 */
private $data;

/**
 * Crumb separator.
 *
 * @var string
 */
private $separator = <li>/</li>;

/**
 * The HTML template to use to render the breadcrumbs.
 *
 * @var TTemplate
 */
private $template;

/**
 * The HTML template to use to render the breadcrumbs.
 *
 * @var Interpolate
 */
private $interpolator;

方法

public function __construct( EscaperInterface $escaper );
抽象帮助器构造函数。

public function __invoke( string $indent = string, string $delimiter = null ): Breadcrumbs;
设置缩进和分隔符,并返回对象本身。

public function add( string $text, string $link = string, string $icon = string, array $attributes = [] ): Breadcrumbs;
添加一个新的面包屑。

// Adding a crumb with a link
$breadcrumbs->add("Home", "/");

// Adding a crumb with added attributes
$breadcrumbs->add("Home", "/", ["class" => "main"]);

// Adding a crumb without a link (normally the last one)
$breadcrumbs->add("Users");

public function clear(): void;
清除面包屑。

$breadcrumbs->clear()

public function clearAttributes(): Breadcrumbs;
清除父元素的属性。

public function getAttributes(): array;
获取父元素的属性。

public function getSeparator(): string;
返回分隔符。

public function getTemplate(): array;
返回当前模板。

public function remove( int $index ): void;
按 URL 删除面包屑。

// Remove the second element
$breadcrumbs->remove(2);

public function render(): string;
基于之前设置的模板渲染并输出面包屑。

echo $breadcrumbs->render();

public function setAttributes( array $attributes ): Breadcrumbs;
设置父元素的属性。

public function setSeparator( string $separator ): Breadcrumbs;
设置分隔符。

public function setTemplate( string $main, string $line, string $last ): Breadcrumbs;
设置 HTML 模板。

public function toArray(): array;
返回内部的面包屑数组。

Html\Helper\Button

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Button

方法

public function __invoke( string $text, array $attributes = [], bool $raw = bool ): string;
生成一个<button> tag.

Html\Helper\Close

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

  • 继承

    AbstractHelper

  • 实现

类 Close

方法

public function __invoke( string $tag, bool $raw = bool ): string;
生成一个</...> tag.

Html\Helper\Doctype

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

  • 继承

  • 实现

创建 Doctype 标签

常量

const HTML32 = 1;
const HTML401_FRAMESET = 4;
const HTML401_STRICT = 2;
const HTML401_TRANSITIONAL = 3;
const HTML5 = 5;
const XHTML10_FRAMESET = 8;
const XHTML10_STRICT = 6;
const XHTML10_TRANSITIONAL = 7;
const XHTML11 = 9;
const XHTML20 = 10;
const XHTML5 = 11;

属性

/**
 * @var string
 */
private $delimiter;

/**
 * @var int
 */
private $flag;

方法

public function __construct();

public function __invoke( int $flag = static-constant-access, string $delimiter = string ): Doctype;
生成一个标签

public function __toString(): string;

Html\Helper\Element

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Element

方法

public function __invoke( string $tag, string $text, array $attributes = [], bool $raw = bool ): string;
生成一个标签。

Html\Helper\Form

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Form

方法

public function __invoke( array $attributes = [] ): string;
生成一个<form> tag.

Html\Helper\Img

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Img

方法

public function __invoke( string $src, array $attributes = [] ): string;
生成一个 tag.

Html\Helper\Input\AbstractInputAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

    • Phalcon\Html\Helper\AbstractHelper
  • 继承

    AbstractHelper

  • 实现

类 AbstractInput

@property array $attributes @property string $type @property string $value

属性

/**
 * @var string
 */
protected $type = text;

/**
 * @var array
 */
protected $attributes;

方法

public function __invoke( string $name, string $value = null, array $attributes = [] ): AbstractInput;

public function __toString();
返回输入元素的 HTML。

public function setValue( string $value = null ): AbstractInput;
设置元素的值

Html\Helper\Input\Checkbox

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

    • Phalcon\Html\Escaper\EscaperInterface
  • 继承

    AbstractInput

  • 实现

类 Checkbox

@property array $label

属性

/**
 * @var array
 */
protected $label;

/**
 * @var string
 */
protected $type = checkbox;

方法

public function __construct( EscaperInterface $escaper );
抽象帮助器构造函数。

public function __toString();
返回输入元素的 HTML。

public function label( array $attributes = [] ): Checkbox;
将标签附加到元素上

Html\Helper\Input\Color

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Color

属性

//
protected $type = color;

Html\Helper\Input\Date

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Date

属性

//
protected $type = date;

Html\Helper\Input\DateTime

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 DateTime

属性

//
protected $type = datetime;

Html\Helper\Input\DateTimeLocal

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 DateTimeLocal

属性

//
protected $type = datetime-local;

Html\Helper\Input\Email

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Email

属性

//
protected $type = email;

Html\Helper\Input\File

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 File

属性

//
protected $type = file;

Html\Helper\Input\Hidden

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Hidden

属性

//
protected $type = hidden;

Html\Helper\Input\Image

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Image

属性

//
protected $type = image;

Html\Helper\Input\Input

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Input

方法

public function setType( string $type ): AbstractInput;
设置输入元素的类型

Html\Helper\Input\Month

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Month

属性

//
protected $type = month;

Html\Helper\Input\Numeric

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Numeric

属性

//
protected $type = number;

Html\Helper\Input\Password

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Password

属性

//
protected $type = password;

Html\Helper\Input\Radio

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    Checkbox

  • 实现

类 Radio

属性

/**
 * @var string
 */
protected $type = radio;

Html\Helper\Input\Range

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Range

属性

//
protected $type = range;

Html\Helper\Input\Search

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Search

属性

//
protected $type = search;

Html\Helper\Input\Select

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

    • Phalcon\Html\Helper\AbstractList
  • 继承

    AbstractList

  • 实现

类 Select

属性

/**
 * @var string
 */
protected $elementTag = option;

/**
 * @var bool
 */
protected $inOptGroup = false;

/**
 * @var string
 */
protected $selected = ;

方法

public function add( string $text, string $value = null, array $attributes = [], bool $raw = bool ): Select;
向列表中添加一个元素

public function addPlaceholder( string $text, mixed $value = null, array $attributes = [], bool $raw = bool ): Select;
向元素添加一个占位符

public function optGroup( string $label = null, array $attributes = [] ): Select;
创建选项组

public function selected( string $selected ): Select;
protected function getTag(): string;
protected function optGroupEnd(): string;
protected function optGroupStart( string $label, array $attributes ): string;

Html\Helper\Input\Submit

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Submit

属性

//
protected $type = submit;

Html\Helper\Input\Tel

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Tel

属性

//
protected $type = tel;

Html\Helper\Input\Text

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Text

Html\Helper\Input\Textarea

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractInput

  • 实现

类 Textarea

属性

/**
 * @var string
 */
protected $type = textarea;

方法

public function __toString();
返回输入元素的 HTML。

Html\Helper\Input\Time

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Time

属性

//
protected $type = time;

Html\Helper\Input\Url

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Url

属性

//
protected $type = url;

Html\Helper\Input\Week

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper\Input
  • 使用

  • 继承

    AbstractInput

  • 实现

类 Week

属性

//
protected $type = week;

Html\Helper\Label

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Label

方法

public function __invoke( string $label, array $attributes = [], bool $raw = bool ): string;
生成一个<label> tag.

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

  • 继承

    Style

  • 实现

创建标签

方法

public function add( string $url, array $attributes = [] );
向列表中添加一个元素

protected function getAttributes( string $url, array $attributes ): array;
返回必要的属性

protected function getTag(): string;

Html\Helper\Meta

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractSeries

  • 实现

类 Meta

方法

public function add( array $attributes = [] ): Meta;
向列表中添加一个元素

public function addHttp( string $httpEquiv, string $content ): Meta;
public function addName( string $name, string $content ): Meta;
public function addProperty( string $name, string $content ): Meta;
protected function getTag(): string;

Html\Helper\Ol

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

  • 继承

    AbstractList

  • 实现

类 Ol

方法

public function add( string $text, array $attributes = [], bool $raw = bool ): AbstractList;
向列表中添加一个元素

protected function getTag(): string;

Html\Helper\Script

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractSeries

  • 实现

类 Script

方法

public function add( string $url, array $attributes = [] );
向列表中添加一个元素

protected function getAttributes( string $url, array $attributes ): array;
返回必要的属性

protected function getTag(): string;

Html\Helper\Style

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractSeries

  • 实现

类 Style

属性

/**
 * @var bool
 */
private $isStyle = false;

方法

public function add( string $url, array $attributes = [] );
向列表中添加一个元素

public function setStyle( bool $flag ): Style;
设置这是 style 还是 link 标签

protected function getAttributes( string $url, array $attributes ): array;
返回必要的属性

protected function getTag(): string;

Html\Helper\Title

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

    • Phalcon\Html\Exception
  • 继承

    AbstractHelper

  • 实现

类 Title

@property array $append @property string $delimiter @property string $indent @property array $prepend @property string $title @property string $separator

属性

/**
 * @var array
 */
protected $append;

/**
 * @var array
 */
protected $prepend;

/**
 * @var string
 */
protected $title = ;

/**
 * @var string
 */
protected $separator = ;

方法

public function __invoke( string $indent = string, string $delimiter = null ): Title;
设置分隔符并返回对象本身

public function __toString();
返回标题标签

public function append( string $text, bool $raw = bool ): Title;
将文本追加到当前文档标题

public function get(): string;
返回标题

public function prepend( string $text, bool $raw = bool ): Title;
将文本前置到当前文档标题

public function set( string $text, bool $raw = bool ): Title;
设置标题

public function setSeparator( string $separator, bool $raw = bool ): Title;
设置分隔符

Html\Helper\Ul

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Helper
  • 使用

  • 继承

    Ol

  • 实现

类 Ul

方法

protected function getTag(): string;

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link
  • 使用

    • Phalcon\Support\Collection
  • 继承

  • 实现

@property array $attributes @property string $href @property array $rels @property bool $templated

属性

/**
 * @var Collection
 */
protected $attributes;

/**
 * @var string
 */
protected $href = ;

/**
 * @var Collection
 */
protected $rels;

/**
 * @var bool
 */
protected $templated = false;

方法

public function __construct( string $rel = string, string $href = string, array $attributes = [] );
链接构造函数。

protected function doGetAttributes(): array;
返回描述目标URI的一组属性。

protected function doGetHref(): string;
返回链接的目标。

目标链接必须是以下之一: - 根据RFC 5988定义的绝对URI。 - 根据RFC 5988定义的相对URI。客户端假定知道相对链接的基准地址基于上下文。 - 根据RFC 6570定义的URI模板。

如果返回的是URI模板,则isTemplated()必须返回True。

protected function doGetRels(): array;
返回链接的关系类型。

此方法返回一个或多个表示链接关系类型的字符串数组。

protected function doIsTemplated(): bool;
返回是否为模板链接。

protected function doWithAttribute( string $key, mixed $value );
protected function doWithHref( string $href );
protected function doWithRel( string $key );
protected function doWithoutAttribute( string $key );
protected function doWithoutRel( string $key );

protected function hrefIsTemplated( string $href ): bool;
判断 href 是否为模板化链接。

@参见 https://tools.ietf.org/html/rfc6570

Html\Link\AbstractLinkProviderAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link
  • 使用

    • Phalcon\Html\Link\Interfaces\LinkInterface
  • 继承

  • 实现

@property array $links

属性

/**
 * @var array
 */
protected $links;

方法

public function __construct( array $links = [] );
LinkProvider 构造函数。

protected function doGetLinks(): array;
返回一个LinkInterface对象的可迭代对象。

可迭代对象可以是一个数组或者任何PHP \Traversable对象。如果没有可用的链接,必须返回一个空数组或\Traversable。

protected function doGetLinksByRel( string $rel ): array;
返回一个具有特定关系的LinkInterface对象的可迭代对象。

可迭代对象可以是一个数组或者任何PHP \Traversable对象。如果没有对应关系的链接,必须返回一个空数组或\Traversable。

protected function doWithLink( mixed $link );
返回一个包含了指定链接的实例。

如果指定的链接已存在,此方法必须正常返回而不报错。当$link与集合中已有的链接对象完全相同(===)时,表示该链接存在。

protected function doWithoutLink( mixed $link );
返回一个移除了指定链接的实例。

如果指定的链接不存在,此方法必须正常返回而不报错。当$link与集合中已有的链接对象完全相同(===)时,表示该链接存在。

protected function getKey( mixed $link ): string;
返回对象的哈希键

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link
  • 使用

    • Phalcon\Html\Link\Interfaces\EvolvableLinkInterface
  • 继承

    Link

  • 实现

    • EvolvableLinkInterface

类 Phalcon\Http\Link\EvolvableLink

@property 数组 attributes @property 字符串 href @property 数组 rels @property 布尔值 templated

方法

public function withAttribute( mixed $attribute, mixed $value ): EvolvableLinkInterface;
返回一个添加了指定属性的实例。

如果指定的属性已经存在,则会被新值覆盖。

public function withHref( string $href ): EvolvableLinkInterface;
返回一个设置了指定href的实例。

public function withRel( string $rel ): EvolvableLinkInterface;
返回一个包含指定关系的实例。

如果指定的关系已存在,此方法必须正常返回而不报错,但不会再次添加该关系。

public function withoutAttribute( string $attribute ): EvolvableLinkInterface;
返回一个去除了指定属性的实例。

如果指定的属性不存在,此方法必须正常返回而不报错。

public function withoutRel( string $rel ): EvolvableLinkInterface;
返回一个去除了指定关系的实例。

如果指定的关系不存在,此方法必须正常返回而不报错。

Html\Link\EvolvableLinkProvider

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link
  • 使用

    • Phalcon\Html\Link\Interfaces\EvolvableLinkProviderInterface
    • Phalcon\Html\Link\Interfaces\LinkInterface
  • 继承

    LinkProvider

  • 实现

    • EvolvableLinkProviderInterface

类 Phalcon\Http\Link\LinkProvider

@property LinkInterface[] links

方法

public function withLink( LinkInterface $link ): EvolvableLinkProviderInterface;
返回一个包含了指定链接的实例。

如果指定的链接已存在,此方法必须正常返回而不报错。当$link与集合中已有的链接对象完全相同(===)时,表示该链接存在。

public function withoutLink( LinkInterface $link ): EvolvableLinkProviderInterface;
返回一个移除了指定链接的实例。

如果指定的链接不存在,此方法必须正常返回而不报错。当link与集合中已有的链接对象完全相同(===)时,表示该链接存在。

Html\Link\Interfaces\EvolvableLinkInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link\Interfaces
  • 使用

  • 继承

    LinkInterface

  • 实现

一个可变链接值对象。

方法

public function withAttribute( string $attribute, string $value ): EvolvableLinkInterface;
返回一个添加了指定属性的实例。

如果指定的属性已经存在,则会被新值覆盖。

public function withHref( string $href ): EvolvableLinkInterface;
返回一个设置了指定href的实例。

public function withRel( string $rel ): EvolvableLinkInterface;
返回一个包含指定关系的实例。

如果指定的关系已存在,此方法必须正常返回而不报错,但不会再次添加该关系。

public function withoutAttribute( string $attribute ): EvolvableLinkInterface;
返回一个去除了指定属性的实例。

如果指定的属性不存在,此方法必须正常返回而不报错。

public function withoutRel( string $rel ): EvolvableLinkInterface;
返回一个去除了指定关系的实例。

如果指定的关系本来就不在其中,此方法必须正常返回而不报错。

Html\Link\Interfaces\EvolvableLinkProviderInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link\Interfaces
  • 使用

  • 继承

    LinkProviderInterface

  • 实现

一个可变链接提供者值对象。

方法

public function withLink( LinkInterface $link ): EvolvableLinkProviderInterface;
返回一个包含了指定链接的实例。

如果指定的链接已存在,此方法必须正常返回而不报错。当$link与集合中已有的链接对象完全相同(===)时,表示该链接存在。

public function withoutLink( LinkInterface $link ): EvolvableLinkProviderInterface;
返回一个移除了指定链接的实例。

如果指定的链接不存在,此方法必须正常返回而不报错。当$link与集合中已有的链接对象完全相同(===)时,表示该链接存在。

Html\Link\Interfaces\LinkInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link\Interfaces
  • 使用

  • 继承

  • 实现

一个可读的链接对象。

方法

public function getAttributes(): array;
返回描述目标URI的一组属性。

public function getHref(): string;
返回链接的目标。

目标链接必须是以下之一: - 根据RFC 5988定义的绝对URI。 - 根据RFC 5988定义的相对URI。客户端假定知道相对链接的基准地址基于上下文。 - 根据RFC 6570定义的URI模板。

如果返回的是URI模板,则isTemplated()必须返回True。

public function getRels(): array;
返回链接的关系类型。

此方法返回一个或多个表示链接关系类型的字符串数组。

public function isTemplated(): bool;
返回是否为模板链接。

Html\Link\Interfaces\LinkProviderInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link\Interfaces
  • 使用

  • 继承

  • 实现

一个链接提供者对象。

方法

public function getLinks(): array;
返回一组LinkInterface对象的数组。

public function getLinksByRel( string $rel ): array;
返回具有特定关系的LinkInterface对象数组。

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link
  • 使用

    • Phalcon\Html\Link\Interfaces\LinkInterface
    • Phalcon\Support\Collection
    • Phalcon\Support\Collection\CollectionInterface
  • 继承

    AbstractLink

  • 实现

    • LinkInterface

类 Phalcon\Http\Link\Link

@property 数组 attributes @property 字符串 href @property 数组 rels @property 布尔值 templated

方法

public function getAttributes(): array;
返回描述目标URI的一组属性。

public function getHref(): string;
返回链接的目标。

目标链接必须是以下之一: - 根据RFC 5988定义的绝对URI。 - 根据RFC 5988定义的相对URI。客户端假定知道相对链接的基准地址基于上下文。 - 根据RFC 6570定义的URI模板。

如果返回的是URI模板,则isTemplated()必须返回True。

public function getRels(): array;
返回链接的关系类型。

此方法返回一个或多个表示链接关系类型的字符串数组。

public function isTemplated(): bool;
返回是否为模板链接。

Html\Link\LinkProvider

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link
  • 使用

    • Phalcon\Html\Link\Interfaces\LinkInterface
    • Phalcon\Html\Link\Interfaces\LinkProviderInterface
  • 继承

    AbstractLinkProvider

  • 实现

    • LinkProviderInterface

@property LinkInterface[] links

方法

public function getLinks(): array;
返回一个LinkInterface对象的可迭代对象。

可迭代对象可以是一个数组或者任何PHP \Traversable对象。如果没有可用的链接,必须返回一个空数组或\Traversable。

public function getLinksByRel( mixed $rel ): array;
返回一个具有特定关系的LinkInterface对象的可迭代对象。

可迭代对象可以是一个数组或者任何PHP \Traversable对象。如果没有对应关系的链接,必须返回一个空数组或\Traversable。

Html\Link\Serializer\Header

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link\Serializer
  • 使用

  • 继承

  • 实现

    • SerializerInterface

类 Phalcon\Http\Link\Serializer\Header

方法

public function serialize( array $links ): string | null;
将所有传入的链接序列化为HTTP链接头

Html\Link\Serializer\SerializerInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Html\Link\Serializer
  • 使用

  • 继承

  • 实现

类 Phalcon\Http\Link\Serializer\SerializerInterface

方法

public function serialize( array $links ): string | null;
序列化器方法

Html\TagFactory

GitHub上的源码

  • 命名空间

    • Phalcon\Html
  • 使用

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Html\Escaper\EscaperInterface
    • Phalcon\Html\Helper\Breadcrumbs
    • Phalcon\Html\Helper\Doctype
    • Phalcon\Html\Helper\Input\Checkbox
    • Phalcon\Html\Helper\Input\Color
    • Phalcon\Html\Helper\Input\Date
    • Phalcon\Html\Helper\Input\DateTime
    • Phalcon\Html\Helper\Input\DateTimeLocal
    • Phalcon\Html\Helper\Input\Email
    • Phalcon\Html\Helper\Input\File
    • Phalcon\Html\Helper\Input\Hidden
    • Phalcon\Html\Helper\Input\Image
    • Phalcon\Html\Helper\Input\Input
    • Phalcon\Html\Helper\Input\Month
    • Phalcon\Html\Helper\Input\Numeric
    • Phalcon\Html\Helper\Input\Password
    • Phalcon\Html\Helper\Input\Radio
    • Phalcon\Html\Helper\Input\Range
    • Phalcon\Html\Helper\Input\Search
    • Phalcon\Html\Helper\Input\Select
    • Phalcon\Html\Helper\Input\Submit
    • Phalcon\Html\Helper\Input\Tel
    • Phalcon\Html\Helper\Input\Text
    • Phalcon\Html\Helper\Input\Textarea
    • Phalcon\Html\Helper\Input\Time
    • Phalcon\Html\Helper\Input\Url
    • Phalcon\Html\Helper\Input\Week
    • Phalcon\Html\Helper\Meta
    • Phalcon\Html\Helper\Ol
    • Phalcon\Html\Helper\Script
    • Phalcon\Html\Helper\Style
    • Phalcon\Html\Helper\Title
    • Phalcon\Html\Helper\Ul
    • Phalcon\Html\Link\Link
  • 继承

    AbstractFactory

  • 实现

Tag辅助工具的服务定位器实现。

服务通过构造函数使用键值对进行注册。键是标签辅助工具的名称,而值是一个返回对象的可调用函数。

该类实现了__call()允许将辅助对象作为方法调用。

@property EscaperInterface $escaper @property array $services

@method string a(string $href, string $text, array $attributes = [], bool $raw = false) @method string base(string $href, array $attributes = []) @method Breadcrumbs breadcrumbs(string $indent = ' ', string $delimiter = "\n") @method string body(array $attributes = []) @method string button(string $text, array $attributes = [], bool $raw = false) @method string close(string $tag, bool $raw = false) @method Doctype doctype(int $flag, string $delimiter) @method string element(string $tag, string $text, array $attributes = [], bool $raw = false) @method string form(array $attributes = []) @method string img(string $src, array $attributes = []) @method Checkbox inputCheckbox(string $name, string $value = null, array $attributes = []) @method Color inputColor(string $name, string $value = null, array $attributes = []) @method Date inputDate(string $name, string $value = null, array $attributes = []) @method DateTime inputDateTime(string $name, string $value = null, array $attributes = []) @method DateTimeLocal inputDateTimeLocal(string $name, string $value = null, array $attributes = []) @method Email inputEmail(string $name, string $value = null, array $attributes = []) @method File inputFile(string $name, string $value = null, array $attributes = []) @method Hidden inputHidden(string $name, string $value = null, array $attributes = []) @method Image inputImage(string $name, string $value = null, array $attributes = []) @method Input inputInput(string $name, string $value = null, array $attributes = []) @method Month inputMonth(string $name, string $value = null, array $attributes = []) @method Numeric inputNumeric(string $name, string $value = null, array $attributes = []) @method Password inputPassword(string $name, string $value = null, array $attributes = []) @method Radio inputRadio(string $name, string $value = null, array $attributes = []) @method Range inputRange(string $name, string $value = null, array $attributes = []) @method Search inputSearch(string $name, string $value = null, array $attributes = []) @method Select inputSelect(string $name, string $value = null, array $attributes = []) @method Submit inputSubmit(string $name, string $value = null, array $attributes = []) @method Tel inputTel(string $name, string $value = null, array $attributes = []) @method Text inputText(string $name, string $value = null, array $attributes = []) @method Textarea inputTextarea(string $name, string $value = null, array $attributes = []) @method Time inputTime(string $name, string $value = null, array $attributes = []) @method Url inputUrl(string $name, string $value = null, array $attributes = []) @method Week inputWeek(string $name, string $value = null, array $attributes = []) @method string label(string $label, array $attributes = [], bool $raw = false) @method Link link(string $indent = ' ', string $delimiter = PHP_EOL) @method Meta meta(string $indent = ' ', string $delimiter = PHP_EOL) @method Ol ol(string $text, array $attributes = [], bool $raw = false) @method Script script(string $indent = ' ', string $delimiter = PHP_EOL) @method Style style(string $indent = ' ', string $delimiter = PHP_EOL) @method Title title(string $indent = ' ', string $delimiter = PHP_EOL) @method Ul ul(string $text, array $attributes = [], bool $raw = false)

属性

/**
 * @var EscaperInterface
 */
private $escaper;

/**
 * @var array
 */
protected $services;

方法

public function __call( string $name, array $arguments );
魔术调用使得辅助对象可以作为方法使用。

public function __construct( EscaperInterface $escaper, array $services = [] );
TagFactory构造函数。

public function has( string $name ): bool;

public function newInstance( string $name ): mixed;
创建一个对象的新实例

public function set( string $name, mixed $method ): void;
protected function getExceptionClass(): string;

protected function getServices(): array;
返回可用的服务

无噪 Logo
无噪文档
25 年 6 月翻译
版本号 5.9
文档源↗