API16

JTableContent/check

From Joomla! Documentation

< API16:JTableContent
Revision as of 17:42, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Overloaded check function <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Overloaded check function

[Edit Descripton]

Template:Description:JTableContent/check

Syntax[edit]

check()


Returns[edit]

boolean

Defined in[edit]

libraries/joomla/database/table/content.php

Importing[edit]

jimport( 'joomla.database.table.content' );

Source Body[edit]

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] Template:SeeAlso:JTableContent/check

Examples[edit]

<CodeExamplesForm />