API16:JTableContent/check
From Joomla! Documentation
Description
Overloaded check function
Syntax
check()
Returns
boolean
Defined in
libraries/joomla/database/table/content.php
Importing
jimport( 'joomla.database.table.content' );
Source Body
public function check()
{
if (empty($this->title)) {
$this->setError(JText::_('Article must have a title'));
return false;
}
if (empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-','',$this->alias)) == '') {
$this->alias = JFactory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S");
}
if (trim(str_replace(' ', '', $this->fulltext)) == '') {
$this->fulltext = '';
}
if (empty($this->introtext) && empty($this->fulltext)) {
$this->setError(JText::_('Article must have some text'));
return false;
}
// clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->metakey)) {
// only process if not empty
$bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters
$keys = explode(',', $after_clean); // create array using commas as delimiter
$clean_keys = array();
foreach($keys as $key) {
if (trim($key)) { // ignore blank keywords
$clean_keys[] = trim($key);
}
}
$this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", "
}
// clean up description -- eliminate quotes and <> brackets
if (!empty($this->metadesc)) {
// only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
}
return true;
}
Examples
Code Examples