10 defined(
'JPATH_PLATFORM') or die;
30 parent::__construct(
'#__menu',
'id', $db);
47 public function bind($array, $ignore =
'')
50 if ($this->home ==
'1' && $this->language ==
'*' && ($array[
'home'] ==
'0'))
52 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT_DEFAULT'));
58 if ($this->home ==
'1' && $this->language ==
'*' && ($array[
'language'] !=
'*'))
60 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT'));
66 if ($this->home ==
'1' && $this->language ==
'*' && $array[
'published'] !=
'1')
68 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME'));
73 if (isset($array[
'params']) && is_array($array[
'params']))
77 $array[
'params'] = (string) $registry;
80 return parent::bind($array, $ignore);
91 public function check()
94 if ($this->type ==
"separator")
96 $this->component_id = 0;
100 $this->alias = trim($this->alias);
102 if ((empty($this->alias)) && ($this->type !=
'alias' && $this->type !=
'url'))
104 $this->alias = $this->title;
110 if (trim(str_replace(
'-',
'', $this->alias)) ==
'')
116 $this->home = (int) $this->home;
119 if ($this->parent_id == 1 && $this->alias ==
'component')
121 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT'));
127 jimport(
'joomla.filesystem.folder');
129 if ($this->parent_id == 1 && in_array($this->alias,
JFolder::folders(JPATH_ROOT)))
131 $this->setError(
JText::sprintf(
'JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias));
137 if ($this->home && $this->type !=
'component')
139 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT'));
157 public function store($updateNulls =
false)
164 if ($table->load(array(
'alias' => $this->alias,
'parent_id' => $this->parent_id,
'client_id' => (
int) $this->client_id,
'language' => $this->language))
165 && ($table->id != $this->
id || $this->
id == 0))
167 if ($this->menutype == $table->menutype)
169 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS'));
173 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS_ROOT'));
180 if ($this->home ==
'1')
184 if ($table->load(array(
'home' =>
'1',
'language' => $this->language)))
186 if ($table->checked_out && $table->checked_out != $this->checked_out)
188 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH'));
194 $table->checked_out = 0;
195 $table->checked_out_time = $db->getNullDate();
200 if ($table->load(array(
'home' =>
'1',
'menutype' => $this->menutype)) && ($table->id != $this->
id || $this->
id == 0))
202 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU'));
208 if (!parent::store($updateNulls))
214 $pathNodes = $this->getPath();
217 foreach ($pathNodes as $node)
220 if ($node->alias !=
'root')
222 $segments[] = $node->alias;
226 $newPath = trim(implode(
'/', $segments),
' /\\');
230 return ($this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0);