10 defined(
'JPATH_PLATFORM') or die;
30 parent::__construct(
'#__categories',
'id', $db);
44 protected function _getAssetName()
48 return $this->extension .
'.category.' . (int) $this->$k;
58 protected function _getAssetTitle()
73 protected function _getAssetParentId(
JTable $table = null, $id = null)
78 if ($this->parent_id > 1)
81 $query = $this->_db->getQuery(
true)
82 ->select($this->_db->quoteName(
'asset_id'))
83 ->from($this->_db->quoteName(
'#__categories'))
84 ->where($this->_db->quoteName(
'id') .
' = ' . $this->parent_id);
87 $this->_db->setQuery($query);
89 if ($result = $this->_db->loadResult())
91 $assetId = (int) $result;
95 elseif ($assetId === null)
98 $query = $this->_db->getQuery(
true)
99 ->select($this->_db->quoteName(
'id'))
100 ->from($this->_db->quoteName(
'#__assets'))
101 ->where($this->_db->quoteName(
'name') .
' = ' . $this->_db->quote($this->extension));
104 $this->_db->setQuery($query);
106 if ($result = $this->_db->loadResult())
108 $assetId = (int) $result;
119 return parent::_getAssetParentId($table, $id);
131 public function check()
134 if (trim($this->title) ==
'')
136 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_CATEGORY'));
141 $this->alias = trim($this->alias);
143 if (empty($this->alias))
145 $this->alias = $this->title;
150 if (trim(str_replace(
'-',
'', $this->alias)) ==
'')
170 public function bind($array, $ignore =
'')
172 if (isset($array[
'params']) && is_array($array[
'params']))
176 $array[
'params'] = (string) $registry;
179 if (isset($array[
'metadata']) && is_array($array[
'metadata']))
182 $registry->
loadArray($array[
'metadata']);
183 $array[
'metadata'] = (string) $registry;
187 if (isset($array[
'rules']) && is_array($array[
'rules']))
190 $this->setRules($rules);
193 return parent::bind($array, $ignore);
205 public function store($updateNulls =
false)
213 $this->modified_time = $date->toSql();
214 $this->modified_user_id = $user->get(
'id');
219 $this->created_time = $date->toSql();
220 $this->created_user_id = $user->get(
'id');
226 if ($table->load(array(
'alias' => $this->alias,
'parent_id' => $this->parent_id,
'extension' => $this->extension))
227 && ($table->id != $this->
id || $this->
id == 0))
229 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
234 return parent::store($updateNulls);