Actions

API15

JTableMenuTypes/check

From Joomla! Documentation

< API15:JTableMenuTypes
Revision as of 13:53, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

boolean


[<! removed edit link to red link >]

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

Syntax

check()


Returns

boolean

Defined in

libraries/joomla/database/table/menutypes.php

Importing

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

Source Body

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

<CodeExamplesForm />