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


PHP Sanitize::html方法代码示例

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


在下文中一共展示了Sanitize::html方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onContentBeforeSave

 /**
  * Finder before save content method
  * Article is passed by reference, but after the save, so no changes will be saved.
  * Method is called right after the content is saved
  *
  * @param   string The context of the content passed to the plugin
  */
 public function onContentBeforeSave($context, &$article, $isNew)
 {
     if (!$article instanceof \Hubzero\Base\Object || $context == 'com_content.article') {
         return;
     }
     $key = $this->_key($context);
     $content = ltrim($article->get($key));
     if (!$content) {
         return;
     }
     // Is there a format already applied?
     if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $content, $matches)) {
         $format = strtolower(trim($matches[1]));
         if ($format != 'html') {
             return;
         }
     } elseif (strstr($content, '</')) {
         // Force apply a format?
         if (!$this->params->get('applyFormat')) {
             return;
         }
     }
     if ($this->params->get('sanitizeBefore', 1)) {
         $content = \Hubzero\Utility\Sanitize::clean($content);
         $content = \Hubzero\Utility\Sanitize::html($content);
     }
     if ($this->params->get('applyFormat')) {
         $content = preg_replace('/^(<!-- \\{FORMAT:HTML\\} -->)/i', '', $content);
         $content = '<!-- {FORMAT:HTML} -->' . $content;
     }
     $article->set($key, $content);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:39,代码来源:formathtml.php

示例2: purify

 /**
  * Purify the HTML content via HTML Purifier
  *
  * @param   string   $content         Unpurified HTML content
  * @param   boolean  $trustedContent  Is the content trusted?
  * @return  string
  */
 public static function purify($content, $trustedContent = false)
 {
     // array to hold options
     $options = array();
     require_once dirname(__DIR__) . DS . 'helpers' . DS . 'filters' . DS . 'GroupInclude.php';
     //create array of custom filters
     $filters = array(new \HTMLPurifier_Filter_GroupInclude());
     // is this trusted content
     if ($trustedContent) {
         require_once dirname(__DIR__) . DS . 'helpers' . DS . 'filters' . DS . 'ExternalScripts.php';
         require_once dirname(__DIR__) . DS . 'helpers' . DS . 'filters' . DS . 'Php.php';
         $options['CSS.Trusted'] = true;
         $options['HTML.Trusted'] = true;
         $filters[] = new \HTMLPurifier_Filter_ExternalScripts();
         $filters[] = new \HTMLPurifier_Filter_Php();
     }
     // add our custom filters
     $options['Filter.Custom'] = $filters;
     // turn OFF linkify
     $options['AutoFormat.Linkify'] = false;
     // run hubzero html sanitize
     return \Hubzero\Utility\Sanitize::html($content, $options);
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:30,代码来源:module.php

示例3: generateFeedTask

 /**
  * Generates RSS feed when called by URL
  *
  * @return  void
  */
 public function generateFeedTask()
 {
     // Get the approved posts
     $model = new Models\Posts();
     $posts = $model->getPostsByStatus(1000, 0, 2);
     // Set the mime encoding for the document
     Document::setType('feed');
     // Start a new feed object
     $doc = Document::instance();
     $doc->title = Config::get('sitename') . ' ' . Lang::txt('COM_FEEDAGGREGATOR_AGGREGATED_FEED');
     $doc->description = Lang::txt(Config::get('sitename') . ' ' . Lang::txt('COM_FEEDAGGREGATOR_AGGREGATED_FEED_SELECTED_READING'));
     $doc->copyright = Lang::txt(date("Y"), Config::get('sitename'));
     $doc->category = Lang::txt('COM_FEEDAGGREGATOR_EXTERNAL_CONTENT');
     // Start outputing results if any found
     if (count($posts) > 0) {
         foreach ($posts as $post) {
             // Load individual item creator class
             $item = new \Hubzero\Document\Type\Feed\Item();
             // sanitize ouput
             $item->title = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $post->title);
             $item->title = preg_replace("/&#?[a-z1-9]{2,8};/i", "", $post->title);
             $item->title = (string) strip_tags($item->title);
             $item->title = html_entity_decode($item->title);
             $item->title = Sanitize::clean($item->title);
             // encapsulate link in unparseable
             $item->link = '<![CDATA[' . $post->link . ']]>';
             $item->date = date($post->created);
             // sanitize ouput
             $item->description = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $post->description);
             $item->description = preg_replace('/[^A-Za-z0-9 ]/', '', $item->description);
             $item->description = preg_replace("/&#?[a-z1-9]{2,8};/i", "", $post->description);
             $item->description = html_entity_decode($post->description);
             $item->description = Sanitize::html($post->description);
             $doc->addItem($item);
         }
     }
     // Output the feed
     echo $doc->render();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:44,代码来源:posts.php

示例4: ucfirst

        }
        echo $this->report->href ? '<a href="' . $this->report->href . '">' : '';
        echo ucfirst($this->cat) . ' by ';
        echo $this->report->anon != 0 ? Lang::txt('COM_SUPPORT_REPORT_ABUSE_ANONYMOUS') : $name;
        echo $this->report->href ? '</a>' : '';
        ?>
</h4>
						<?php 
        echo $this->report->subject ? '<p><strong>' . stripslashes($this->report->subject) . '</strong></p>' : '';
        ?>
						<blockquote cite="<?php 
        echo $this->report->anon != 0 ? Lang::txt('COM_SUPPORT_ANONYMOUS') : $name;
        ?>
">
							<p><?php 
        echo Sanitize::html($this->report->text);
        ?>
</p>
						</blockquote>
					</div>
				</div>
				<?php 
    }
    ?>

				<p class="multiple-option">
					<label class="option" for="subject1"><input type="radio" class="option" name="subject" id="subject1" value="<?php 
    echo Lang::txt('COM_SUPPORT_REPORT_ABUSE_OFFENSIVE');
    ?>
" checked="checked" /> <?php 
    echo Lang::txt('COM_SUPPORT_REPORT_ABUSE_OFFENSIVE');
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:display.php


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