当前位置: 首页>>代码示例>>PHP>>正文


PHP HtmlHelper::open_tag方法代码示例

本文整理汇总了PHP中HtmlHelper::open_tag方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlHelper::open_tag方法的具体用法?PHP HtmlHelper::open_tag怎么用?PHP HtmlHelper::open_tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlHelper的用法示例。


在下文中一共展示了HtmlHelper::open_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;
 }
开发者ID:setola,项目名称:wordpress-theme-utils-classes,代码行数:78,代码来源:LipsumGenerator.class.php


注:本文中的HtmlHelper::open_tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。