API15:JTableMenuTypes/check
From Joomla! Documentation
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
Code Examples