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


PHP SpoonFilter::htmlentities方法代码示例

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


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

示例1: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     $limit = (int) $this->get('fork.settings')->get('Search', 'autocomplete_num_items', 10);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // get matches
         $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
         // get search url
         $url = FrontendNavigation::getURLForBlock('Search');
         // loop items and set search url
         foreach ($matches as &$match) {
             $match['url'] = $url . '?form=search&q=' . $match['term'];
         }
         // output
         $this->output(self::OK, $matches);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:28,代码来源:Autocomplete.php

示例2: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     // validate search term
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // previous search result
         $previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : '';
         \SpoonSession::set('searchTerm', '');
         // save this term?
         if ($previousTerm != $term) {
             // format data
             $this->statistics = array();
             $this->statistics['term'] = $term;
             $this->statistics['language'] = LANGUAGE;
             $this->statistics['time'] = FrontendModel::getUTCDate();
             $this->statistics['data'] = serialize(array('server' => $_SERVER));
             $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
             // save data
             FrontendSearchModel::save($this->statistics);
         }
         // save current search term in cookie
         \SpoonSession::set('searchTerm', $term);
         // output
         $this->output(self::OK);
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:35,代码来源:Save.php

示例3: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @param	bool[optional] $allowHTML	Is HTML allowed?
  * @return	string
  */
 public function getValue($allowHTML = null)
 {
     // redefine default value
     $value = $this->value;
     // added to form
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post/get (may be empty)
         if (isset($data[$this->attributes['name']])) {
             // value
             $value = $data[$this->getName()];
             $value = is_scalar($value) ? (string) $value : 'Array';
             if (!$allowHTML) {
                 $value = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
             }
         }
     }
     return $value;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:26,代码来源:hidden.php

示例4: getMethod

 /**
  * Retrieve the method post/get.
  *
  * @return	string
  */
 public function getMethod()
 {
     // prevent against xss
     $method = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($this->method) : SpoonFilter::htmlentities($this->method);
     return $method;
 }
开发者ID:sunkangtaichi,项目名称:library,代码行数:11,代码来源:form.php

示例5: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @return	string
  * @param	bool[optional] $allowHTML	Is HTML allowed?
  */
 public function getValue($allowHTML = null)
 {
     // redefine html & default value
     $allowHTML = $allowHTML !== null ? (bool) $allowHTML : $this->isHTML;
     $value = $this->value;
     // contains html
     if ($this->isHTML) {
         // set value
         $value = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
     }
     // form submitted
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post (may be empty)
         if (isset($data[$this->getName()])) {
             // value
             $value = $data[$this->attributes['name']];
             // maximum length?
             if (isset($this->attributes['maxlength']) && $this->attributes['maxlength'] > 0) {
                 $value = mb_substr($value, 0, (int) $this->attributes['maxlength'], SPOON_CHARSET);
             }
             // html allowed?
             if (!$allowHTML) {
                 $value = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
             }
         }
     }
     return $value;
 }
开发者ID:jincongho,项目名称:clienthub,代码行数:36,代码来源:textarea.php

示例6: testHtmlentities

 public function testHtmlentities()
 {
     // setup
     $input = 'Ik heb "géén" bananen vandaag';
     $expectedResult = 'Ik heb "géén" bananen vandaag';
     // perform test
     $this->assertEquals($expectedResult, SpoonFilter::htmlentities(utf8_decode($input), 'iso-8859-1'));
     $this->assertEquals($expectedResult, SpoonFilter::htmlentities($input, 'utf-8'));
     $expectedResult = 'Ik heb "géén" bananen vandaag';
     $this->assertEquals($expectedResult, SpoonFilter::htmlentities($input, null, ENT_QUOTES));
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:11,代码来源:SpoonFilterTest.php

示例7: readFromFeed

 /**
  * Reads an feed into a SpoonRSS object.
  *
  * @return	SpoonRSS					Returns as an instance of SpoonRSS.
  * @param	string $URL					An URL where the feed is located or the XML of the feed.
  * @param	string[optional] $type		The type of feed, possible values are: url, string.
  */
 public static function readFromFeed($URL, $type = 'url')
 {
     // redefine var
     $URL = (string) $URL;
     $type = (string) SpoonFilter::getValue($type, array('url', 'string'), 'url');
     // validate
     if ($type == 'url' && !SpoonFilter::isURL($URL)) {
         throw new SpoonFeedException('This (' . SpoonFilter::htmlentities($URL) . ') isn\'t a valid URL.');
     }
     if (!self::isValid($URL, $type)) {
         throw new SpoonFeedException('Invalid feed');
     }
     // load xmlstring
     if ($type == 'url') {
         $xmlString = SpoonHTTP::getContent($URL);
     } else {
         $xmlString = $URL;
     }
     // convert to simpleXML
     $XML = @simplexml_load_string($xmlString);
     // validate the feed
     if ($XML === false) {
         throw new SpoonFeedException('Invalid rss-string.');
     }
     // get title, link and description
     $title = (string) $XML->channel->title;
     $link = (string) $XML->channel->link;
     $description = (string) $XML->channel->description;
     // create instance
     $RSS = new SpoonFeedRSS($title, $link, $description);
     // add items
     foreach ($XML->channel->item as $item) {
         // try to read
         try {
             // read xml
             $item = SpoonFeedRSSItem::readFromXML($item);
             $RSS->addItem($item);
         } catch (Exception $e) {
             // ignore exceptions
         }
     }
     // add category
     if (isset($XML->channel->category)) {
         foreach ($XML->channel->category as $category) {
             if (isset($category['domain'])) {
                 $RSS->addCategory((string) $category, (string) $category['domain']);
             } else {
                 $RSS->addCategory((string) $category);
             }
         }
     }
     // add skip day
     if (isset($XML->channel->skipDays)) {
         // loop ski-days
         foreach ($XML->channel->skipDays->day as $day) {
             // try to add
             try {
                 // add skip-day
                 $RSS->addSkipDay((string) $day);
             } catch (Exception $e) {
                 // ignore exceptions
             }
         }
     }
     // add skip hour
     if (isset($XML->channel->skipHours)) {
         foreach ($XML->channel->skipHours->hour as $hour) {
             // try to add
             try {
                 // add skip hour
                 $RSS->addSkipHour((int) $hour);
             } catch (Exception $e) {
                 // ignore exceptions
             }
         }
     }
     // set cloud
     if (isset($XML->channel->cloud['domain']) && isset($XML->channel->cloud['port']) && isset($XML->channel->cloud['path']) && isset($XML->channel->cloud['registerProce-dure']) && isset($XML->channel->cloud['protocol'])) {
         // read attributes
         $cloudDomain = (string) $XML->channel->cloud['domain'];
         $cloudPort = (int) $XML->channel->cloud['port'];
         $cloudPath = (string) $XML->channel->cloud['path'];
         $cloudRegisterProcedure = (string) $XML->channel->cloud['registerProce-dure'];
         $cloudProtocol = (string) $XML->channel->cloud['protocol'];
         // set property
         $RSS->setCloud($cloudDomain, $cloudPort, $cloudPath, $cloudRegisterProcedure, $cloudProtocol);
     }
     // set copyright
     if (isset($XML->channel->copyright)) {
         $copyright = (string) $XML->channel->copyright;
         $RSS->setCopyright($copyright);
     }
     // set docs
//.........这里部分代码省略.........
开发者ID:jincongho,项目名称:clienthub,代码行数:101,代码来源:rss.php

示例8: setConfirm

 /**
  * Sets the confirm message.
  *
  * @return	void
  * @param	string $message
  * @param	string[optional] $custom
  */
 public function setConfirm($message, $custom = null)
 {
     $this->confirm = true;
     $this->confirmMessage = SpoonFilter::htmlentities((string) $message);
     $this->confirmCustom = (string) $custom;
 }
开发者ID:ss23,项目名称:ECommerce,代码行数:13,代码来源:datagrid.php

示例9: parseSeo

 /**
  * Parse SEO specific data
  */
 private function parseSeo()
 {
     // when on the homepage of the default language, set the clean site url as canonical, because of redirect fix
     $queryString = trim($this->URL->getQueryString(), '/');
     $language = $this->get('fork.settings')->get('Core', 'default_language', SITE_DEFAULT_LANGUAGE);
     if ($queryString == $language) {
         $this->canonical = rtrim(SITE_URL, '/');
         if ($this->getContainer()->getParameter('site.multilanguage')) {
             $this->canonical .= '/' . $language;
         }
     }
     // any canonical URL provided?
     if ($this->canonical != '') {
         $url = $this->canonical;
     } else {
         // get the chunks of the current url
         $urlChunks = parse_url($this->URL->getQueryString());
         // a canonical url should contain the domain. So make sure you
         // redirect your website to a single url with .htaccess
         $url = rtrim(SITE_URL, '/');
         if (isset($urlChunks['port'])) {
             $url .= ':' . $urlChunks['port'];
         }
         if (isset($urlChunks['path'])) {
             $url .= '/' . $urlChunks['path'];
         }
         // any items provided through GET?
         if (isset($urlChunks['query'])) {
             // the items we should add into the canonical url
             $itemsToAdd = array('page');
             $addToUrl = array();
             // loop all items in GET and check if we should ignore them
             foreach ($_GET as $key => $value) {
                 if (in_array($key, $itemsToAdd)) {
                     $addToUrl[$key] = $value;
                 }
             }
             // add GET-params
             if (!empty($addToUrl)) {
                 $url .= '?' . http_build_query($addToUrl);
             }
         }
     }
     // prevent against xss
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $url = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($url) : \SpoonFilter::htmlentities($url);
     $this->addLink(array('rel' => 'canonical', 'href' => $url));
     if ($this->get('fork.settings')->get('Core', 'seo_noodp', false)) {
         $this->addMetaData(array('name' => 'robots', 'content' => 'noodp'));
     }
     if ($this->get('fork.settings')->get('Core', 'seo_noydir', false)) {
         $this->addMetaData(array('name' => 'robots', 'content' => 'noydir'));
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:57,代码来源:Header.php

示例10: validateForm

 /**
  * Validate the form
  */
 private function validateForm()
 {
     // set search term
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $this->term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     // validate
     if ($this->term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:14,代码来源:Livesuggest.php

示例11: validateForm

 /**
  * Validate the form
  */
 private function validateForm()
 {
     // set search term
     $searchTerm = SpoonFilter::getPostValue('term', null, '');
     $this->term = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($searchTerm) : SpoonFilter::htmlentities($searchTerm);
     // validate
     if ($this->term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:13,代码来源:livesuggest.php

示例12: readFromFeed

 /**
  * Reads an feed into a SpoonRSS object.
  *
  * @return	SpoonAtomRSS				Returns as an instance of SpoonAtomRSS.
  * @param	string $URL					An URL where the feed is located or the XML of the feed.
  * @param	string[optional] $type		The type of feed, possible values are: url, string.
  * @param	bool[optional] $force		Force to read this feed without validation.
  */
 public static function readFromFeed($URL, $type = 'url', $force = false)
 {
     // redefine var
     $URL = (string) $URL;
     $type = (string) SpoonFilter::getValue($type, array('url', 'string'), 'url');
     // validate
     if ($type == 'url' && !SpoonFilter::isURL($URL)) {
         throw new SpoonFeedException('This (' . SpoonFilter::htmlentities($URL) . ') isn\'t a valid URL.');
     }
     if (!$force) {
         if (!self::isValid($URL, $type)) {
             throw new SpoonFeedException('Invalid feed');
         }
     }
     // load xmlstring
     if ($type == 'url') {
         $xmlString = SpoonHTTP::getContent($URL);
     } else {
         $xmlString = $URL;
     }
     // convert to simpleXML
     $XML = @simplexml_load_string($xmlString);
     // validate the feed
     if ($XML === false) {
         throw new SpoonFeedException('Invalid rss-string.');
     }
     // get title, link and description
     $title = (string) $XML->title;
     $id = (string) $XML->id;
     // create instance
     $RSS = new SpoonFeedAtomRSS($title, $id);
     // add authors
     if (isset($XML->author)) {
         foreach ($XML->author as $author) {
             // get the values
             $author['name'] = (string) $XML->author->name;
             $author['email'] = isset($XML->author->email) ? (string) $XML->author->email : null;
             $author['uri'] = isset($XML->author->uri) ? (string) $XML->author->uri : null;
             // set the values
             $RSS->addAuthor($author);
         }
     }
     // add contributors
     if (isset($XML->contributor)) {
         foreach ($XML->contributor as $contributor) {
             $name = (string) $contributor['name'];
             $email = isset($contributor['scheme']) ? (string) $contributor['email'] : null;
             $uri = isset($contributor['label']) ? (string) $contributor['uri$contributor'] : null;
             // set property
             $RSS->addContributor($name, $email, $uri);
         }
     }
     // add categories
     if (isset($XML->category)) {
         foreach ($XML->category as $category) {
             // build category
             $cat['term'] = (string) $category['term'];
             if (isset($category['scheme'])) {
                 $cat['scheme'] = (string) $category['scheme'];
             }
             if (isset($category['label'])) {
                 $cat['label'] = (string) $category['label'];
             }
             // set property
             $RSS->addCategory($cat);
         }
     }
     // add links
     if (isset($XML->link)) {
         foreach ($XML->link as $link) {
             // build link
             $aLink['href'] = $link['href'];
             if (isset($link['rel'])) {
                 $aLink['rel'] = $link['rel'];
             }
             if (isset($link['type'])) {
                 $aLink['type'] = $link['type'];
             }
             if (isset($link['title'])) {
                 $aLink['title'] = $link['title'];
             }
             if (isset($link['hreflang'])) {
                 $aLink['hreflang'] = $link['hreflang'];
             }
             if (isset($link['length'])) {
                 $aLink['length'] = $link['length'];
             }
             // set property
             $RSS->addLink($aLink);
         }
     }
     // add items
//.........这里部分代码省略.........
开发者ID:sunkangtaichi,项目名称:library,代码行数:101,代码来源:atom_rss.php

示例13: parseSeo

 /**
  * Parse SEO specific data
  */
 private function parseSeo()
 {
     // any canonical URL provided?
     if ($this->canonical != '') {
         $url = $this->canonical;
     } else {
         // get the chunks of the current url
         $urlChunks = parse_url($this->URL->getQueryString());
         // a canonical url should contain the domain. So make sure you redirect your website to a single url with .htaccess
         $url = rtrim(SITE_URL, '/');
         if (isset($urlChunks['port'])) {
             $url .= ':' . $urlChunks['port'];
         }
         if (isset($urlChunks['path'])) {
             $url .= '/' . $urlChunks['path'];
         }
         // any items provided through GET?
         if (isset($urlChunks['query'])) {
             // the items we should add into the canonical url
             $itemsToAdd = array('page');
             $addToUrl = array();
             // loop all items in GET and check if we should ignore them
             foreach ($_GET as $key => $value) {
                 if (in_array($key, $itemsToAdd)) {
                     $addToUrl[$key] = $value;
                 }
             }
             // add GET-params
             if (!empty($addToUrl)) {
                 $url .= '?' . http_build_query($addToUrl);
             }
         }
     }
     // prevent against xss
     $url = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($url) : SpoonFilter::htmlentities($url);
     // canonical
     $this->addLink(array('rel' => 'canonical', 'href' => $url));
     // noodp, noydir
     if (FrontendModel::getModuleSetting('core', 'seo_noodp', false)) {
         $this->addMetaData(array('name' => 'robots', 'content' => 'noodp'));
     }
     if (FrontendModel::getModuleSetting('core', 'seo_noydir', false)) {
         $this->addMetaData(array('name' => 'robots', 'content' => 'noydir'));
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:48,代码来源:header.php


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