當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。