本文整理汇总了PHP中CHtmlPurifier::purify方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtmlPurifier::purify方法的具体用法?PHP CHtmlPurifier::purify怎么用?PHP CHtmlPurifier::purify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtmlPurifier
的用法示例。
在下文中一共展示了CHtmlPurifier::purify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearch
function actionSearch($q = null, $page = 1)
{
$pages = new CPagination();
$pages->pageSize = 50;
$pages->currentPage = $page;
$p = new CHtmlPurifier();
$q = CHtml::encode($p->purify($q));
$searchCriteria = new stdClass();
$searchCriteria->select = 'id';
$searchCriteria->query = $q . '*';
$searchCriteria->paginator = $pages;
$searchCriteria->from = join(",", $this->indexes);
// Получаем данные в виде массива
$resArray = Yii::App()->search->searchRaw($searchCriteria);
$news = null;
if (is_array($resArray['matches'])) {
$c = new CDbCriteria();
$c->order = 'FIELD(id,' . join(",", array_keys($resArray['matches'])) . ')';
$news = News::model()->findAllByPk(array_keys($resArray['matches']), $c);
}
$this->render("search_results", array('news' => $news));
}
示例2: purifyHtml
protected function purifyHtml($html)
{
// remove bad parsing
$html = preg_replace('#\\\\r\\\\n|\\\\r|\\\\n|\\\\#sui', '', $html);
$p = new CHtmlPurifier();
$p->options = array('HTML.Allowed' => 'img[src],p,br,b,strong,i');
$html = $p->purify($html);
$p->options = array('HTML.Allowed' => '');
$text = $p->purify($html);
if (mb_strlen($text, 'UTF-8') === mb_strlen($html, 'UTF-8')) {
return '<pre>' . $text . '</pre>';
}
return $html;
}
示例3: safeTransform
public function safeTransform($content)
{
$content = $this->transform($content);
$purifier = new CHtmlPurifier();
$purifier->options = $this->purifierOptions;
return $purifier->purify($content);
}
示例4: ergebnisse2FeedData
/**
* @param \Solarium\QueryType\Select\Result\Result $ergebnisse
* @return array();
*/
public static function ergebnisse2FeedData($ergebnisse)
{
$data = array();
$dokumente = $ergebnisse->getDocuments();
$highlighting = $ergebnisse->getHighlighting();
$purifier = new CHtmlPurifier();
$purifier->options = array('URI.AllowedSchemes' => array('http' => true, 'https' => true));
foreach ($dokumente as $dokument) {
$model = Dokument::getDocumentBySolrId($dokument->id);
$risitem = $model->getRISItem();
if (!$risitem) {
continue;
}
$link = $risitem->getLink();
$highlightedDoc = $highlighting->getResult($dokument->id);
$item = array("title" => $model->name . " (zu " . $risitem->getTypName() . " \"" . $risitem->getName() . "\"", "link" => $link, "content" => "", "dateCreated" => RISTools::date_iso2timestamp(str_replace("T", " ", str_replace("Z", "", $dokument->sort_datum))), "aenderung_guid" => $link);
if ($highlightedDoc && count($highlightedDoc) > 0) {
foreach ($highlightedDoc as $highlight) {
$item["content"] .= $purifier->purify(implode(' (...) ', $highlight)) . '<br/>';
}
}
$data[] = $item;
}
return $data;
}
示例5: htmlPurifier
/**
* 对内容进行过滤 未使用
*/
public static function htmlPurifier($content)
{
$p = new CHtmlPurifier();
//过滤规则
$p->options = array('URI.Disable' => true);
return $p->purify($content);
}
示例6: Purify
public function Purify($value)
{
$p = new CHtmlPurifier();
$p->options = array('HTML.Allowed' => 'strong,em,u,h1,h2,h3,h4');
$cleanHtml = $p->purify($value);
return $cleanHtml;
}
示例7: safehtml
public function safehtml($attr, $params)
{
$p = new CHtmlPurifier();
$p->options = Yii::app()->params["HTMLPurifierOptions"];
$p->options["HTML.Allowed"] = "a[href],b,strong,i,em,u,small,sub,sup";
$this->{$attr} = trim($p->purify($this->{$attr}));
}
示例8: purifyText
public function purifyText($attribute, $params)
{
$module = Yii::app()->getModule('comment');
$p = new CHtmlPurifier();
$p->options = ['HTML.Allowed' => $module->allowedTags];
$this->{$attribute} = $p->purify($this->{$attribute});
}
示例9: processOutput
/**
* Processes the captured output.
* This method converts the content in markdown syntax to HTML code.
* If {@link purifyOutput} is true, the HTML code will also be purified.
* @param string $output the captured output to be processed
* @see convert
*/
public function processOutput($output)
{
$output = $this->transform($output);
if ($this->purifyOutput) {
$purifier = new CHtmlPurifier();
$output = $purifier->purify($output);
}
parent::processOutput($output);
}
示例10: beforeSave
/**
* Manage the created fields
*/
public function beforeSave()
{
if ($this->isNewRecord) {
$this->created = time();
}
$p = new CHtmlPurifier();
$this->subject = $p->purify($this->subject);
return parent::beforeSave();
}
示例11: process
/**
* Process a string with markup
*
* @abstract
* @param string $input
* @return string $output
*/
public function process($input)
{
$out = $this->processMarkup($input);
if ($this->purify) {
$purifier = new CHtmlPurifier();
$out = $purifier->purify($out);
}
return $out;
}
示例12: filterString
public static function filterString($string)
{
$string = strip_tags($string);
$string = stripcslashes($string);
$string = htmlspecialchars($string);
$p = new CHtmlPurifier();
$string = $p->purify($string);
$string = addslashes($string);
$string = str_replace("\r\n", "\n", $string);
return $string;
}
示例13: actionHtmlPurifier
public function actionHtmlPurifier()
{
$user_input = null;
if (isset($_POST['user_input'])) {
$user_input = $_POST['user_input'];
}
$parser = new CHtmlPurifier();
//create instance of CHtmlPurifier
$user_input = $parser->purify($user_input);
//we purify the $user_input
$this->render("htmlpurifier", array('user_input' => $user_input));
}
示例14: run
public function run()
{
$this->markdown = CHtml::encode($this->markdown);
$parserClass = $this->parserClass;
$parser = new $parserClass();
$html = $parser->parse($this->markdown);
if ($this->purifyOutput) {
$purifier = new CHtmlPurifier();
$html = $purifier->purify($html);
}
$this->render('markdownView', array('content' => $html));
}
示例15: actionSave
/**
* Required POSTED data are :
* phone_number - required - number
* dispo_name - required - any
* @return void
*/
public function actionSave()
{
header("Content-Type: application/json");
$returnResult = ['status' => "", 'message' => ""];
$p = new CHtmlPurifier();
$disposaleForm = new DisposaleForm();
$disposaleForm->dispo_name = $p->purify(@$_POST['dispo_name']);
$disposaleForm->phone_number = $p->purify(@$_POST['phone_number']);
$disposaleForm->posted_data = json_encode(@$_POST);
if ($disposaleForm->validate()) {
if ($disposaleForm->save()) {
$returnResult['status'] = 'success';
$returnResult['message'] = "New dispo sale saved";
} else {
$returnResult['status'] = 'failed';
$returnResult['message'] = CHtml::errorSummary($disposaleForm);
}
} else {
$returnResult['status'] = 'failed';
$returnResult['message'] = CHtml::errorSummary($disposaleForm);
}
echo json_encode($returnResult);
}