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


PHP helpers\HtmlPurifier类代码示例

本文整理汇总了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));
 }
开发者ID:Sywooch,项目名称:find-parser,代码行数:12,代码来源:Parser.php

示例2: pageSlug

 /**
  * returns page slug if set
  * @return string
  */
 public function pageSlug()
 {
     if (isset($_GET['slug'])) {
         return HtmlPurifier::process($_GET['slug']);
     }
     return false;
 }
开发者ID:perminder-klair,项目名称:kato-core,代码行数:11,代码来源:Kato.php

示例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]);
 }
开发者ID:rocketyang,项目名称:admap,代码行数:27,代码来源:View.php

示例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) {
     }
 }
开发者ID:huynt57,项目名称:bluebee-ng,代码行数:32,代码来源:SearchController.php

示例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();
 }
开发者ID:Rudianasaja,项目名称:yiifeed,代码行数:27,代码来源:NewsController.php

示例6: processthemessage

 private function processthemessage($message)
 {
     $Dbfactory = DbFactory::getinstance();
     $message = $Dbfactory->dbSqlProtected($message);
     $message = \yii\helpers\HtmlPurifier::process($message);
     return $message;
 }
开发者ID:merjiezo,项目名称:suesyiban_MIS,代码行数:7,代码来源:OwnTodos.php

示例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;
 }
开发者ID:kartik-v,项目名称:yii2-grid,代码行数:33,代码来源:ExportController.php

示例8: beforeSave

 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->value = HtmlPurifier::process($this->value);
         return true;
     }
     return false;
 }
开发者ID:msdie,项目名称:yii2-module-comments,代码行数:8,代码来源:CommentsFields.php

示例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>';
 }
开发者ID:cinghie,项目名称:yii2-articles,代码行数:8,代码来源:ItemWidget.php

示例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'));
     }]];
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:11,代码来源:Message.php

示例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]];
 }
开发者ID:aekkapun,项目名称:yii2-podium,代码行数:11,代码来源:Meta.php

示例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]];
 }
开发者ID:bolom009,项目名称:testwork_api,代码行数:11,代码来源:Blog.php

示例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']];
 }
开发者ID:AtuinCMS,项目名称:static_page,代码行数:11,代码来源:StaticPlugin.php

示例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]];
 }
开发者ID:aekkapun,项目名称:yii2-podium,代码行数:11,代码来源:Post.php

示例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;
 }
开发者ID:vait,项目名称:allinst,代码行数:8,代码来源:RegionActiveRecord.php


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