本文整理汇总了PHP中HtmlHelper::close_tag方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlHelper::close_tag方法的具体用法?PHP HtmlHelper::close_tag怎么用?PHP HtmlHelper::close_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper::close_tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_rich_html
/**
* Generates and renders in rich html format
* @see LipsumGenerator::FORMAT_RICH_HTML
* @return LipsumGenerator $this for chainability
*/
private function render_rich_html()
{
$this->render = '';
$is_first_p = true;
$this->stats = array();
// useful to avoid the same tag to be repeated without plain text between
$last_closed_tag = false;
if (empty($this->rich_html_config)) {
$this->set_rich_html_config();
}
for ($i = 0; $i < $this->number_of_paragraphs; $i++) {
$paragraph = $this->get_paragraph();
$rendered_p = '';
if ($is_first_p) {
$this->force_beginning(&$paragraph);
} else {
$rendered_p .= "\n";
}
$rendered_p .= HtmlHelper::open_tag('p');
//'<p>';
foreach ($paragraph as $sentence) {
// stores the currently opened html tag
$current_tag = '';
// stores how many words are left before the current tag have to be closed
$words_until_close_tag = 0;
foreach ($sentence as $index => $word) {
if ($words_until_close_tag < 0) {
$words_until_close_tag = 0;
}
if (empty($current_tag) && empty($last_closed_tag)) {
$tag_to_add = '';
foreach ($this->rich_html_config as $tag => $tag_config) {
$rnd = rand(0, 99);
if ($rnd < $tag_config['percent']) {
//v(array($rnd, $tag, $index));
if (isset($this->rich_html_config[$tag_to_add]['percent']) && $this->rich_html_config[$tag_to_add]['percent'] < $tag_config['percent']) {
$tag_to_add = $tag;
$this->stats[$tag]++;
}
}
}
}
if (!empty($tag_to_add)) {
// insert the current tag!
$current_tag = $tag_to_add;
//$rendered_p .= $this->open_tag($tag_to_add);
$rendered_p .= HtmlHelper::open_tag($tag_to_add, $this->rich_html_config[$tag_to_add]['params']);
$words_until_close_tag = rand(1, $this->rich_html_config[$tag_to_add]['max_words']);
$tag_to_add = '';
}
$rendered_p .= $word;
$last_closed_tag = '';
if (!empty($current_tag)) {
if ($words_until_close_tag == 0) {
$rendered_p .= HtmlHelper::close_tag($current_tag);
$last_closed_tag = $current_tag;
$current_tag = '';
} else {
$words_until_close_tag--;
}
}
$rendered_p .= ' ';
}
// close the last tag if it's still open at the paragraph end
$rendered_p .= HtmlHelper::close_tag($current_tag);
}
$rendered_p .= HtmlHelper::close_tag('p');
//"</p>";
$this->render .= $rendered_p;
$is_first_p = false;
}
return $this;
}