10 defined(
'JPATH_PLATFORM') or die;
31 parent::__construct(
'#__content',
'id', $db);
54 protected function _getAssetName()
58 return 'com_content.article.' . (int) $this->$k;
68 protected function _getAssetTitle()
83 protected function _getAssetParentId(JTable $table = null, $id = null)
91 $query = $this->_db->getQuery(
true)
92 ->select($this->_db->quoteName(
'asset_id'))
93 ->from($this->_db->quoteName(
'#__categories'))
94 ->where($this->_db->quoteName(
'id') .
' = ' . (int) $this->catid);
97 $this->_db->setQuery($query);
99 if ($result = $this->_db->loadResult())
101 $assetId = (int) $result;
112 return parent::_getAssetParentId($table, $id);
128 public function bind($array, $ignore =
'')
131 if (isset($array[
'articletext']))
133 $pattern =
'#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
134 $tagPos = preg_match($pattern, $array[
'articletext']);
138 $this->introtext = $array[
'articletext'];
139 $this->fulltext =
'';
143 list ($this->introtext, $this->fulltext) = preg_split($pattern, $array[
'articletext'], 2);
147 if (isset($array[
'attribs']) && is_array($array[
'attribs']))
151 $array[
'attribs'] = (string) $registry;
154 if (isset($array[
'metadata']) && is_array($array[
'metadata']))
157 $registry->
loadArray($array[
'metadata']);
158 $array[
'metadata'] = (string) $registry;
162 if (isset($array[
'rules']) && is_array($array[
'rules']))
165 $this->setRules($rules);
168 return parent::bind($array, $ignore);
179 public function check()
181 if (trim($this->title) ==
'')
183 $this->setError(
JText::_(
'COM_CONTENT_WARNING_PROVIDE_VALID_NAME'));
188 if (trim($this->alias) ==
'')
190 $this->alias = $this->title;
195 if (trim(str_replace(
'-',
'', $this->alias)) ==
'')
200 if (trim(str_replace(
' ',
'', $this->fulltext)) ==
'')
202 $this->fulltext =
'';
206 if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up)
209 $temp = $this->publish_up;
210 $this->publish_up = $this->publish_down;
211 $this->publish_down = $temp;
216 if (!empty($this->metakey))
221 $bad_characters = array(
"\n",
"\r",
"\"",
"<",
">");
227 $keys = explode(
',', $after_clean);
229 $clean_keys = array();
231 foreach ($keys as $key)
236 $clean_keys[] = trim($key);
240 $this->metakey = implode(
", ", $clean_keys);
255 public function store($updateNulls =
false)
263 $this->modified = $date->toSql();
264 $this->modified_by = $user->get(
'id');
270 if (!(
int) $this->created)
272 $this->created = $date->toSql();
275 if (empty($this->created_by))
277 $this->created_by = $user->get(
'id');
284 if ($table->load(array(
'alias' => $this->alias,
'catid' => $this->catid)) && ($table->id != $this->
id || $this->
id == 0))
286 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS'));
291 return parent::store($updateNulls);
307 public function publish($pks = null, $state = 1, $userId = 0)
309 $k = $this->_tbl_key;
313 $userId = (int) $userId;
314 $state = (int) $state;
321 $pks = array($this->$k);
326 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
333 $where = $k .
'=' . implode(
' OR ' . $k .
'=', $pks);
336 if (!property_exists($this,
'checked_out') || !property_exists($this,
'checked_out_time'))
342 $checkin =
' AND (checked_out = 0 OR checked_out = ' . (int) $userId .
')';
346 $query = $this->_db->getQuery(
true)
347 ->update($this->_db->quoteName($this->_tbl))
348 ->
set($this->_db->quoteName(
'state') .
' = ' . (int) $state)
349 ->where(
'(' . $where .
')' . $checkin);
350 $this->_db->setQuery($query);
354 $this->_db->execute();
356 catch (RuntimeException $e)
358 $this->setError($e->getMessage());
364 if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
367 foreach ($pks as $pk)
374 if (in_array($this->$k, $pks))
376 $this->state = $state;