本文整理汇总了PHP中yii\helpers\HtmlPurifier类的典型用法代码示例。如果您正苦于以下问题:PHP HtmlPurifier类的具体用法?PHP HtmlPurifier怎么用?PHP HtmlPurifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HtmlPurifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPage
public static function getPage($url)
{
sleep(self::$timeout);
self::$timeout = 2;
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'));
$htmlpurifier_config = \HTMLPurifier_Config::createDefault();
$htmlpurifier_config->set('Attr.EnableID', true);
// $htmlpurifier_config->set('Attr.EnableID', true);
$purifier = new HtmlPurifier($htmlpurifier_config);
return $purifier->process(curl_exec($curl));
}
示例2: pageSlug
/**
* returns page slug if set
* @return string
*/
public function pageSlug()
{
if (isset($_GET['slug'])) {
return HtmlPurifier::process($_GET['slug']);
}
return false;
}
示例3: run
public function run($id, $title)
{
$id = (int) $id;
$cacheKey = __NAMESPACE__ . __CLASS__ . 'adver.view' . $id;
$cache = Yii::$app->getCache();
if (!($model = $cache->get($cacheKey))) {
$model = Adver::find()->with(['attachment' => function ($query) {
$query->select(['id', 'adver_id', 'name', 'title']);
}, 'gallery' => function ($query) {
$query->select(['id', 'adver_id', 'name', 'title']);
}, 'category' => function ($query) {
$query->select(['id', 'name']);
}, 'country' => function ($query) {
$query->select(['id', 'name']);
}, 'province' => function ($query) {
$query->select(['id', 'name']);
}, 'city' => function ($query) {
$query->select(['id', 'name']);
}])->where(['id' => $id, 'status' => Adver::STATUS_ACTIVE, 'lang' => ['*', Yii::$app->language]])->asArray()->one();
if (!$model) {
throw new \yii\web\NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
}
$model['description'] = HtmlPurifier::process($model['description']);
$cache->set($cacheKey, $model, 2592000, new \yii\caching\DbDependency(['sql' => "SELECT [[updated_at]] FROM {{%adver}} WHERE [[id]] = :id AND [[status]] = :status", 'params' => [':id' => $id, ':status' => Adver::STATUS_ACTIVE]]));
}
return $this->controller->render('view', ['model' => $model]);
}
示例4: actionIndex
public function actionIndex()
{
$request = Yii::$app->request;
try {
$query = $request->get('search-string', '');
$query = HtmlPurifier::process($query);
Yii::$app->view->title = 'Kết quả tìm kiếm cho ' . $query;
Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => 'Bluebee-UET.com - Kết quả tìm kiếm cho ' . $query]);
Yii::$app->view->registerMetaTag(['property' => 'og:title', 'content' => 'Bluebee-UET.com - Kết quả tìm kiếm cho ' . $query]);
Yii::$app->view->registerMetaTag(['property' => 'og:description', 'content' => 'Bluebee-UET.com - Kết quả tìm kiếm cho ' . $query]);
Yii::$app->view->registerMetaTag(['property' => 'og:image', 'content' => 'http://bluebee-uet.com/img/logo.jpg']);
$attr = $request->get('attr', '');
switch ($attr) {
case 'teacher':
$data = Teachers::searchTeachers(strtolower($query));
break;
case 'document':
$data = Documents::searchDocuments(strtolower($query));
break;
case 'subject':
$data = Subjects::searchSubjects(strtolower($query));
break;
default:
$this->redirect('http://bluebee-uet.com');
break;
}
$data['attr'] = $attr;
$data['query'] = $query;
return $this->render('index', $data);
} catch (Exception $ex) {
}
}
示例5: actionRss
public function actionRss()
{
/** @var News[] $news */
$news = News::find()->where(['status' => News::STATUS_PUBLIC])->orderBy('id DESC')->limit(50)->all();
$feed = new Feed();
$feed->title = 'YiiFeed';
$feed->link = Url::to('');
$feed->selfLink = Url::to(['news/rss'], true);
$feed->description = 'Yii news';
$feed->language = 'en';
$feed->setWebMaster('sam@rmcreative.ru', 'Alexander Makarov');
$feed->setManagingEditor('sam@rmcreative.ru', 'Alexander Makarov');
foreach ($news as $post) {
$item = new Item();
$item->title = $post->title;
$item->link = Url::to(['news/view', 'id' => $post->id], true);
$item->guid = Url::to(['news/view', 'id' => $post->id], true);
$item->description = HtmlPurifier::process(Markdown::process($post->text));
if (!empty($post->link)) {
$item->description .= Html::a(Html::encode($post->link), $post->link);
}
$item->pubDate = $post->created_at;
$item->setAuthor('noreply@yiifeed.com', 'YiiFeed');
$feed->addItem($item);
}
$feed->render();
}
示例6: processthemessage
private function processthemessage($message)
{
$Dbfactory = DbFactory::getinstance();
$message = $Dbfactory->dbSqlProtected($message);
$message = \yii\helpers\HtmlPurifier::process($message);
return $message;
}
示例7: actionDownload
/**
* Download the exported file
*
* @return mixed
*/
public function actionDownload()
{
$request = Yii::$app->request;
$type = $request->post('export_filetype', 'html');
$name = $request->post('export_filename', Yii::t('kvgrid', 'export'));
$content = $request->post('export_content', Yii::t('kvgrid', 'No data found'));
$mime = $request->post('export_mime', 'text/plain');
$encoding = $request->post('export_encoding', 'utf-8');
$bom = $request->post('export_bom', true);
$config = $request->post('export_config', '{}');
if ($type == GridView::PDF) {
$config = Json::decode($config);
$this->generatePDF($content, "{$name}.pdf", $config);
/** @noinspection PhpInconsistentReturnPointsInspection */
return;
} elseif ($type == GridView::HTML) {
$content = HtmlPurifier::process($content);
} elseif ($type == GridView::CSV || $type == GridView::TEXT) {
if ($encoding != 'utf-8') {
$content = mb_convert_encoding($content, $encoding, 'utf-8');
} elseif ($bom) {
$content = chr(239) . chr(187) . chr(191) . $content;
// add BOM
}
}
$this->setHttpHeaders($type, $name, $mime, $encoding);
return $content;
}
示例8: beforeSave
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
$this->value = HtmlPurifier::process($this->value);
return true;
}
return false;
}
示例9: run
public function run()
{
$item = Items::find()->where(['id' => $this->id])->one();
return '<div class="articleWidget articleWidget-' . $this->id . ' ' . $this->classes . '">
<h3><a href="' . $item->getItemUrl() . '" title="' . Html::encode($item->title) . '">' . Html::encode($item->title) . '</a></h3>
<div class="widgetText">' . HtmlPurifier::process($item->introtext) . '</div>
</div>';
}
示例10: rules
/**
* @inheritdoc
*/
public function rules()
{
return [[['receiver_id', 'topic', 'content'], 'required'], ['receiver_id', 'validateReceiver'], ['topic', 'string', 'max' => 255], ['topic', 'filter', 'filter' => function ($value) {
return HtmlPurifier::process($value);
}], ['content', 'filter', 'filter' => function ($value) {
return HtmlPurifier::process($value, Helper::podiumPurifierConfig('full'));
}]];
}
示例11: rules
/**
* @inheritdoc
*/
public function rules()
{
return [[['location', 'signature'], 'trim'], ['location', 'filter', 'filter' => function ($value) {
return HtmlPurifier::process(Html::encode($value));
}], ['gravatar', 'boolean'], ['image', 'image', 'mimeTypes' => 'image/png, image/jpeg, image/gif', 'maxWidth' => self::MAX_WIDTH, 'maxHeight' => self::MAX_HEIGHT, 'maxSize' => self::MAX_SIZE], ['signature', 'filter', 'filter' => function ($value) {
return HtmlPurifier::process($value, Helper::podiumPurifierConfig('minimal'));
}], ['signature', 'string', 'max' => 512]];
}
示例12: rules
/**
* @inheritdoc
*/
public function rules()
{
return [[['content'], 'filter', 'filter' => function ($value) {
return \yii\helpers\HtmlPurifier::process($value, ['HTML.Allowed' => self::$ALLOWED_TAGS]);
}], [['title'], 'filter', 'filter' => function ($value) {
return \yii\helpers\HtmlPurifier::process($value, ['HTML.Allowed' => '']);
}], [['categorys'], 'inCategories'], [['title', 'content'], 'required'], [['content'], 'string', 'max' => 1000], [['created_at', 'updated_at', 'user_id'], 'integer'], [['title'], 'string', 'max' => 255]];
}
示例13: rules
/**
* @inheritdoc
*/
public function rules()
{
Validator::$builtInValidators['uri'] = 'cyneek\\yii2\\widget\\urlparser\\validators\\UriValidator';
return [[['title', 'url', 'text'], 'required'], [['id', 'author_id', 'last_editor_id'], 'integer'], [['creation_date', 'update_date'], 'string'], [['text'], 'string', 'encoding' => 'utf8'], [['title'], 'string', 'length' => [5, 255]], [['url'], 'uri'], [['text'], function ($attribute) {
// Maybe adding
$this->{$attribute} = \yii\helpers\HtmlPurifier::process($this->{$attribute});
}], [['id', 'title', 'url', 'text'], 'safe']];
}
示例14: rules
/**
* @inheritdoc
*/
public function rules()
{
return [['topic', 'required', 'message' => Yii::t('podium/view', 'Topic can not be blank.'), 'on' => ['firstPost']], ['topic', 'filter', 'filter' => function ($value) {
return HtmlPurifier::process(Html::encode($value));
}, 'on' => ['firstPost']], ['subscribe', 'boolean'], ['content', 'required'], ['content', 'filter', 'filter' => function ($value) {
return HtmlPurifier::process($value, Helper::podiumPurifierConfig('full'));
}], ['content', 'string', 'min' => 10]];
}
示例15: toArray
public function toArray($queryResult)
{
$regions = [];
foreach ($queryResult as $region) {
$regions[] = ['id' => HtmlPurifier::process(stripslashes($region->idRegion)), 'name' => HtmlPurifier::process(stripslashes($region->vch_name)), 'day_way' => HtmlPurifier::process(stripslashes($region->num_day_way))];
}
return $regions;
}