php yii-helpers-HtmlPurifier类(方法)实例源码

下面列出了php yii-helpers-HtmlPurifier 类(方法)源码代码实例,从而了解它的用法。

作者:Sywooc    项目:find-parse   
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));
 }

作者:perminder-klai    项目:kato-cor   
/**
  * returns page slug if set
  * @return string
  */
 public function pageSlug()
 {
     if (isset($_GET['slug'])) {
         return HtmlPurifier::process($_GET['slug']);
     }
     return false;
 }

作者:rocketyan    项目:adma   
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]);
 }

作者:huynt5    项目:bluebee-n   
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) {
     }
 }

作者:Rudianasaj    项目:yiifee   
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();
 }

作者:merjiez    项目:suesyiban_MI   
private function processthemessage($message)
 {
     $Dbfactory = DbFactory::getinstance();
     $message = $Dbfactory->dbSqlProtected($message);
     $message = \yii\helpers\HtmlPurifier::process($message);
     return $message;
 }

作者:kartik-    项目:yii2-gri   
/**
  * 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;
 }

作者:msdi    项目:yii2-module-comment   
public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->value = HtmlPurifier::process($this->value);
         return true;
     }
     return false;
 }

作者:cinghi    项目:yii2-article   
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>';
 }

作者:Avenger    项目:yii2-podiu   
/**
  * @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'));
     }]];
 }

作者:aekkapu    项目:yii2-podiu   
/**
  * @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]];
 }

作者:bolom00    项目:testwork_ap   
/**
  * @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]];
 }

作者:AtuinCM    项目:static_pag   
/**
  * @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']];
 }

作者:aekkapu    项目:yii2-podiu   
/**
  * @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]];
 }

作者:vai    项目:allins   
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;
 }

作者:vai    项目:allins   
public function toArray($queryResult)
 {
     $couriers = [];
     foreach ($queryResult as $courier) {
         $couriers[] = ['id' => HtmlPurifier::process(stripslashes($courier->idCourier)), 'firstName' => HtmlPurifier::process(stripslashes($courier->vch_first_name)), 'lastName' => HtmlPurifier::process(stripslashes($courier->vch_last_name)), 'middleName' => HtmlPurifier::process(stripslashes($courier->vch_middle_name))];
     }
     return $couriers;
 }

作者:keltst    项目:yii2-podiu   
/**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['content', 'topic'], 'required'], [['content', 'topic'], 'string', 'min' => 1], ['topic', 'filter', 'filter' => function ($value) {
         return HtmlPurifier::process($value);
     }], ['content', 'filter', 'filter' => function ($value) {
         return HtmlPurifier::process($value, Helper::podiumPurifierConfig('full'));
     }]];
 }

作者:fanin    项目:gtq   
/**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'alias'], 'value' => function ($event) {
         return Inflector::slug($event->sender->title);
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm'));
     }]];
 }

作者:pezis    项目:yii2-podiu   
/**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['topic', 'content'], 'required'], [['receiversId', 'friendsId'], 'each', 'rule' => ['integer', 'min' => 1]], ['sender_status', 'in', 'range' => self::getStatuses()], ['topic', 'string', 'max' => 255], ['topic', 'filter', 'filter' => function ($value) {
         return HtmlPurifier::process($value);
     }], ['content', 'filter', 'filter' => function ($value) {
         return HtmlPurifier::process($value, Helper::podiumPurifierConfig('minimal'));
     }]];
 }

作者:bolom00    项目:testwork_ap   
/**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['description'], 'filter', 'filter' => function ($value) {
         return \yii\helpers\HtmlPurifier::process($value, ['HTML.Allowed' => self::$ALLOWED_TAGS]);
     }], [['name'], 'filter', 'filter' => function ($value) {
         return \yii\helpers\HtmlPurifier::process($value, ['HTML.Allowed' => '']);
     }], [['status', 'user_id'], 'integer'], ['status', 'in', 'range' => [self::STATUS_ON, self::STATUS_OFF]], [['name', 'description'], 'required'], [['name', 'description'], 'string', 'max' => 255]];
 }


问题


面经


文章

微信
公众号

扫码关注公众号