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


PHP Sanitize::stripWhitespace方法代码示例

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


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

示例1: _save

 function _save($params)
 {
     $this->action = 'index';
     $isNew = Sanitize::getInt($this->data['FieldOption'], 'optionid') ? false : true;
     $text = Sanitize::getString($this->data['FieldOption'], 'text');
     $value = Sanitize::stripAll($this->data['FieldOption'], 'value');
     $field_id = Sanitize::getInt($this->data['FieldOption'], 'fieldid');
     $location = Sanitize::getString($this->data, 'location', 'content');
     $limit = $this->limit;
     $limitstart = $this->offset;
     $total = 0;
     // Begin validation
     $validation_ids = array();
     $text == '' and $validation_ids[] = "option_text";
     $value == '' and $validation_ids[] = "option_value";
     if (!empty($validation_ids)) {
         return json_encode(compact('validation_ids'));
     }
     // Begin save
     $result = $this->FieldOption->save($this->data);
     if ($result != 'success') {
         $msg = "An option with this value already exists for this field.";
         return $this->ajaxError($msg);
     }
     // Begin update display
     $option_id = $this->data['FieldOption']['optionid'];
     $field_id = $this->data['FieldOption']['fieldid'];
     $rows = $this->FieldOption->getList($field_id, $limitstart, $limit, $total);
     $this->_db->setQuery("\n            SELECT \n                fieldid,type,name,title,groupid,location \n            FROM \n                #__jreviews_fields \n            WHERE \n                fieldid = " . $field_id);
     $field = current($this->_db->loadAssocList());
     // Reloads the whole list to display the new/updated record
     $page = Sanitize::stripWhitespace($this->listViewTable($rows, $total, $field));
     $action = 'success';
     return json_encode(compact('action', 'page', 'option_id'));
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:35,代码来源:fieldoptions_controller.php

示例2: testStripWhitespace

 /**
  * testStripWhitespace method
  *
  * @return void
  */
 public function testStripWhitespace()
 {
     $string = "This     sentence \t\t\t has lots of \n\n white\nspace \rthat \r\n needs to be    \t    \n trimmed.";
     $expected = "This sentence has lots of whitespace that needs to be trimmed.";
     $result = Sanitize::stripWhitespace($string);
     $this->assertEquals($expected, $result);
     $text = 'I    love  ßá†ö√    letters.';
     $result = Sanitize::stripWhitespace($text);
     $expected = 'I love ßá†ö√ letters.';
     $this->assertEquals($result, $expected);
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:16,代码来源:SanitizeTest.php

示例3: testStripWhitespace

 /**
  * testStripWhitespace method
  *
  * @access public
  * @return void
  */
 function testStripWhitespace()
 {
     $string = "This     sentence \t\t\t has lots of \n\n white\nspace \rthat \r\n needs to be    \t    \n trimmed.";
     $expected = "This sentence has lots of whitespace that needs to be trimmed.";
     $result = Sanitize::stripWhitespace($string);
     $this->assertEqual($result, $expected);
 }
开发者ID:BGCX067,项目名称:fambom-svn-to-git,代码行数:13,代码来源:sanitize.test.php

示例4: makeJS

 function makeJS($js)
 {
     $js = Sanitize::stripWhitespace($js);
     if ($js != '') {
         return '<script type="text/javascript">' . (is_array($js) ? implode('', $js) : $js) . '</script>';
     }
     return '';
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:8,代码来源:controller.php

示例5: stripAll

 /**
  * Strips extra whitespace, images, scripts and stylesheets from output
  *
  * @param string $str String to sanitize
  * @return string sanitized string
  * @access public
  */
 function stripAll($str)
 {
     $str = Sanitize::stripWhitespace($str);
     $str = Sanitize::stripImages($str);
     $str = Sanitize::stripScripts($str);
     return $str;
 }
开发者ID:kevinmel2000,项目名称:Study-Buddy---CakePHP-Quiz-System,代码行数:14,代码来源:sanitize.php

示例6: stripAll

/**
 * Strips extra whitespace, images, scripts and stylesheets from output
 *
 * @param string $str String to sanitize
 * @return string sanitized string
 */
	public static function stripAll($str) {
		return Sanitize::stripScripts(
			Sanitize::stripImages(
				Sanitize::stripWhitespace($str)
			)
		);
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:13,代码来源:Sanitize.php

示例7: _save

 function _save()
 {
     /*******************************************************************
      * This method is processed inside an iframe
      * To access any of the DOM elements via jQuery it's necessary to prepend
      * all jQuery calls with $parentFrame (i.e. $parentFrame.jQuery)
      ********************************************************************/
     $this->autoRender = false;
     $this->autoLayout = false;
     $response = array();
     $parentFrame = 'window.parent';
     $validation = '';
     $listing_id = Sanitize::getInt($this->data['Listing'], 'id', 0);
     $isNew = $this->Listing->isNew = $listing_id == 0 ? true : false;
     $this->data['email'] = Sanitize::getString($this->data, 'email');
     $this->data['name'] = Sanitize::getString($this->data, 'name');
     $this->data['categoryid_hidden'] = Sanitize::getInt($this->data['Listing'], 'categoryid_hidden');
     $cat_id = Sanitize::getVar($this->data['Listing'], 'catid');
     $this->data['Listing']['catid'] = is_array($cat_id) ? (int) array_pop(array_filter($cat_id)) : (int) $cat_id;
     /*J16*/
     $this->data['Listing']['title'] = Sanitize::getString($this->data['Listing'], 'title', '');
     $this->data['Listing']['created_by_alias'] = Sanitize::getString($this->data, 'name', '');
     if ($this->cmsVersion == CMS_JOOMLA15) {
         $this->data['sectionid_hidden'] = Sanitize::getInt($this->data['Listing'], 'sectionid_hidden');
         $this->data['Listing']['sectionid'] = Sanitize::getInt($this->data['Listing'], 'sectionid');
     } else {
         $this->data['Listing']['language'] = '*';
         $this->data['Listing']['access'] = 1;
     }
     $category_id = $this->data['Listing']['catid'] ? $this->data['Listing']['catid'] : $this->data['categoryid_hidden'];
     # Get criteria info
     $criteria = $this->Criteria->findRow(array('conditions' => array('Criteria.id = 
             (SELECT criteriaid FROM #__jreviews_categories WHERE id = ' . (int) $category_id . ' AND `option` = "com_content")
         ')));
     if (!$criteria) {
         $validation = __t("The category selected is invalid.", true, true);
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     $this->data['Criteria']['id'] = $criteria['Criteria']['criteria_id'];
     # Override global configuration
     isset($criteria['ListingType']) and $this->Config->override($criteria['ListingType']['config']);
     # Perform access checks
     if ($isNew && !$this->Access->canAddListing()) {
         return $this->makeJS("{$parentFrame}.s2Alert('" . __t("You are not allowed to submit listings in this category.", true, true) . "')");
     } elseif (!$isNew) {
         $query = "SELECT created_by FROM #__content WHERE id = " . $listing_id;
         $this->_db->setQuery($query);
         $listing_owner = $this->_db->loadResult();
         if (!$this->Access->canEditListing($listing_owner)) {
             return $this->makeJS("{$parentFrame}.s2Alert('" . s2Messages::accessDenied() . "')");
         }
     }
     # Load the notifications observer model component and initialize it.
     # Done here so it only loads on save and not for all controlller actions.
     $this->components = array('security', 'notifications');
     $this->__initComponents();
     if ($this->invalidToken == true) {
         return $this->makeJS("{$parentFrame}.s2Alert('" . s2Messages::invalidToken() . "')");
     }
     # Override configuration
     $category = $this->Category->findRow(array('conditions' => array('Category.id = ' . $this->data['Listing']['catid'])));
     $this->Config->override($category['ListingType']['config']);
     if ($this->Access->loadWysiwygEditor()) {
         $this->data['Listing']['introtext'] = Sanitize::stripScripts(Sanitize::stripWhitespace(Sanitize::getVar($this->data['__raw']['Listing'], 'introtext')));
         $this->data['Listing']['fulltext'] = Sanitize::stripScripts(Sanitize::stripWhitespace(Sanitize::getVar($this->data['__raw']['Listing'], 'fulltext')));
         $this->data['Listing']['introtext'] = html_entity_decode($this->data['Listing']['introtext'], ENT_QUOTES, cmsFramework::getCharset());
         $this->data['Listing']['fulltext'] = html_entity_decode($this->data['Listing']['fulltext'], ENT_QUOTES, cmsFramework::getCharset());
     } else {
         $this->data['Listing']['introtext'] = Sanitize::stripAll($this->data['Listing'], 'introtext', '');
         if (isset($this->data['Listing']['fulltext'])) {
             $this->data['Listing']['fulltext'] = Sanitize::stripAll($this->data['Listing'], 'fulltext', '');
         } else {
             $this->data['Listing']['fulltext'] = '';
         }
     }
     $this->data['Listing']['introtext'] = str_replace('<br>', '<br />', $this->data['Listing']['introtext']);
     $this->data['Listing']['fulltext'] = str_replace('<br>', '<br />', $this->data['Listing']['fulltext']);
     if ($this->Access->canAddMeta()) {
         $this->data['Listing']['metadesc'] = Sanitize::getString($this->data['Listing'], 'metadesc');
         $this->data['Listing']['metakey'] = Sanitize::getString($this->data['Listing'], 'metakey');
     }
     // Title alias handling
     $slug = '';
     $alias = Sanitize::getString($this->data['Listing'], 'alias');
     if ($isNew && $alias == '') {
         $slug = S2Router::sefUrlEncode($this->data['Listing']['title']);
         if (trim(str_replace('-', '', $slug)) == '') {
             $slug = date("Y-m-d-H-i-s");
         }
     } elseif ($alias != '') {
         // Alias filled in so we convert it to a valid alias
         $slug = S2Router::sefUrlEncode($alias);
         if (trim(str_replace('-', '', $slug)) == '') {
             $slug = date("Y-m-d-H-i-s");
         }
     }
     $slug != '' and $this->data['Listing']['alias'] = $slug;
//.........这里部分代码省略.........
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:101,代码来源:listings_controller.php


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