JTableMenuTypes/check: Difference between revisions
From Joomla! Documentation
m removing red link to edit, no existant pages |
m preparing for archive only |
||
| Line 76: | Line 76: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=check | category=check | ||
category=JTableMenuTypes | category=JTableMenuTypes | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 01:11, 25 March 2017
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