Actions

API16

JTableContent/check

From Joomla! Documentation

< API16:JTableContent
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Overloaded check function

[Edit Descripton]

Description:JTableContent/check

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('&nbsp;', '', $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;
}

[Edit See Also] SeeAlso:JTableContent/check

Examples

<CodeExamplesForm />