english/administrator/components/com_newsfeeds/tables/newsfeed.php
/**
	 * Overloaded check method to ensure data integrity.
	 *
	 * @return	boolean	True on success.
	 */
Overloaded check method to ensure data integrity.
@return      boolean True on success.
Overloaded check method to ensure data integrity . @return boolean True on success .
function check()
	{
		if (trim($this->name) == '') {
			$this->setError(JText::_('COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME'));
			return false;
		}
		if (empty($this->alias)) {
			$this->alias = $this->name;
		}
		$this->alias = JApplication::stringURLSafe($this->alias);
		if (trim(str_replace('-','',$this->alias)) == '') {
			$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
		}
		if (intval($this->publish_down) > 0 && $this->publish_down < $this->publish_up) {
			$temp = $this->publish_up;
			$this->publish_up = $this->publish_down;
			$this->publish_down = $temp;
		}
		if (!empty($this->metakey)) {
			$bad_characters = array("\n", "\r", "\"", "<", ">"); 
			$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); 
			$keys = explode(',', $after_clean); 
			$clean_keys = array();
			foreach($keys as $key) {
				if (trim($key)) {  
					$clean_keys[] = trim($key);
				}
			}
			$this->metakey = implode(", ", $clean_keys); 
		}
		if (!empty($this->metadesc)) {
			$bad_characters = array("\"", "<", ">");
			$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
		}
		return true;
	}
function check ( ) { if ( trim ( $ this -> name ) == '' ) { $ this -> setError ( JText :: _ ( 'COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME' ) ) ; return false ; } if ( empty ( $ this -> alias ) ) { $ this -> alias = $ this -> name ; } $ this -> alias = JApplication :: stringURLSafe ( $ this -> alias ) ; if ( trim ( str_replace ( '-' , '' , $ this -> alias ) ) == '' ) { $ this -> alias = JFactory :: getDate ( ) -> format ( " Y-m-d-H-i-s " ) ; } if ( intval ( $ this -> publish_down ) > 0 && $ this -> publish_down < $ this -> publish_up ) { $ temp = $ this -> publish_up ; $ this -> publish_up = $ this -> publish_down ; $ this -> publish_down = $ temp ; } if ( ! empty ( $ this -> metakey ) ) { $ bad_characters = array ( " \n " , " \r " , " \" " , " < " , " > " ) ; $ after_clean = JString :: str_ireplace ( $ bad_characters , " " , $ this -> metakey ) ; $ keys = explode ( ',' , $ after_clean ) ; $ clean_keys = array ( ) ; foreach ( $ keys as $ key ) { if ( trim ( $ key ) ) { $ clean_keys [ ] = trim ( $ key ) ; } } $ this -> metakey = implode ( " ,  " , $ clean_keys ) ; } if ( ! empty ( $ this -> metadesc ) ) { $ bad_characters = array ( " \" " , " < " , " > " ) ; $ this -> metadesc = JString :: str_ireplace ( $ bad_characters , " " , $ this -> metadesc ) ; } return true ; }
Overloaded check method to ensure data integrity.
Overloaded check method to ensure data integrity .
// Check for valid name. // Check the publish down date is not earlier than publish up. // Swap the dates. // clean up keywords -- eliminate extra spaces between phrases // and cr (\r) and lf (\n) characters from string // only process if not empty // array of characters to remove // remove bad characters // create array using commas as delimiter // ignore blank keywords // put array back together delimited by ", " // clean up description -- eliminate quotes and <> brackets // only process if not empty