API15

JTableMenuTypes/check

From Joomla! Documentation

< API15:JTableMenuTypes
Revision as of 13:53, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)

The "API15" 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]

boolean


[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

check()


Returns[edit]

boolean

Defined in[edit]

libraries/joomla/database/table/menutypes.php

Importing[edit]

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

Source Body[edit]

function check()
{
        
        $this->menutype = str_replace('-', ' ', $this->menutype);

        $lang =& JFactory::getLanguage();
        $this->menutype = $lang->transliterate($this->menutype);

        $this->menutype = preg_replace(array('/\s+/','/[^A-Za-z0-9\-\_]/'), array('-',''), $this->menutype);

        $this->menutype = trim(strtolower($this->menutype));
        
        if(empty($this->menutype)) {
                $this->setError( "Cannot save: Empty menu type" );
                return false;
        }

        // correct spurious data
        if (trim( $this->title) == '') {
                $this->title = $this->menutype;
        }

        $db             =& JFactory::getDBO();

        // check for unique menutype for new menu copy
        $query = 'SELECT menutype' .
                        ' FROM #__menu_types';
        if ($this->id) {
                $query .= ' WHERE id != '.(int) $this->id;
        }

        $db->setQuery( $query );
        $menus = $db->loadResultArray();

        foreach ($menus as $menutype)
        {
                if ($menutype == $this->menutype)
                {
                        $this->setError( "Cannot save: Duplicate menu type '{$this->menutype}'" );
                        return false;
                }
        }

        return true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />