Source for file corecontent.php
Documentation is available at corecontent.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @package Joomla.Libraries
* @param JDatabaseDriver $db A database connector object
parent::__construct('#__ucm_content', 'core_content_id', $db);
* Overloaded bind function
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding.
* @return mixed Null if operation was satisfactory, otherwise returns an error string
public function bind($array, $ignore =
'')
if (isset
($array['core_params']) &&
is_array($array['core_params']))
$registry->loadArray($array['core_params']);
$array['core_params'] = (string)
$registry;
if (isset
($array['core_metadata']) &&
is_array($array['core_metadata']))
$registry->loadArray($array['core_metadata']);
$array['core_metadata'] = (string)
$registry;
if (isset
($array['core_images']) &&
is_array($array['core_images']))
$registry->loadArray($array['core_images']);
$array['core_images'] = (string)
$registry;
if (isset
($array['core_urls']) &&
is_array($array['core_urls']))
$registry->loadArray($array['core_urls']);
$array['core_urls'] = (string)
$registry;
if (isset
($array['core_body']) &&
is_array($array['core_body']))
$registry->loadArray($array['core_body']);
$array['core_body'] = (string)
$registry;
return parent::bind($array, $ignore);
* Overloaded check function
* @return boolean True on success, false on failure
if (trim($this->core_title) ==
'')
if (trim($this->core_alias) ==
'')
$this->core_alias =
$this->core_title;
// Check the publish down date is not earlier than publish up.
if ($this->core_publish_down >
$this->_db->getNullDate() &&
$this->core_publish_down <
$this->core_publish_up)
$temp =
$this->core_publish_up;
$this->core_publish_up =
$this->core_publish_down;
$this->core_publish_down =
$temp;
// Clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->core_metakey))
// Only process if not empty
// Array of characters to remove
$bad_characters =
array("\n", "\r", "\"", "<", ">");
// Create array using commas as delimiter
$keys =
explode(',', $after_clean);
$clean_keys[] =
trim($key);
// Put array back together delimited by ", "
$this->core_metakey =
implode(", ", $clean_keys);
* Override JTable delete method to include deleting corresponding row from #__ucm_base.
* @param integer $pk primary key value to delete. Must be set or throws an exception.
* @return boolean True on success.
* @throws UnexpectedValueException
public function delete($pk =
null)
return parent::delete($pk) &&
$baseTable->delete($pk);
* Method to delete a row from the #__ucm_content table by content_item_id.
* @param integer $contentItemId value of the core_content_item_id to delete. Corresponds to the primary key of the content table.
* @return boolean True on success.
* @throws UnexpectedValueException
if ($contentItemId ===
null ||
((int)
$contentItemId) ===
0)
throw
new UnexpectedValueException('Null content item key not allowed.');
$query =
$db->getQuery(true);
$query->select($db->quoteName('core_content_id'))
->from($db->quoteName('#__ucm_content'))
->where($db->quoteName('core_content_item_id') .
' = ' . (int)
$contentItemId);
if ($ucmId =
$db->loadResult())
* Overrides JTable::store to set modified data and user id.
* @param boolean $updateNulls True to update fields even if they are null.
* @return boolean True on success.
public function store($updateNulls =
false)
if ($this->core_content_id)
$this->core_modified_time =
$date->toSql();
$this->core_modified_user_id =
$user->get('id');
// New content item. A content item core_created_time and core_created_user_id field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int)
$this->core_created_time)
$this->core_created_time =
$date->toSql();
if (empty($this->core_created_user_id))
$this->core_created_user_id =
$user->get('id');
$result =
parent::store($updateNulls);
return $result &&
$this->storeUcmBase($updateNulls, $isNew);
* Insert or update row in ucm_base table
* @param boolean $updateNulls True to update fields even if they are null.
* @param boolean $isNew if true, need to insert. Otherwise update.
* @return boolean True on success.
protected function storeUcmBase($updateNulls =
false, $isNew =
false)
// Store the ucm_base row
$query =
$db->getQuery(true);
$query->insert($db->quoteName('#__ucm_base'))
->columns(array($db->quoteName('ucm_id'), $db->quoteName('ucm_item_id'), $db->quoteName('ucm_type_id'), $db->quoteName('ucm_language_id')))
$db->quote($this->core_content_id) .
', '
.
$db->quote($this->core_content_item_id) .
', '
.
$db->quote($this->core_type_id) .
', '
.
$db->quote($languageId)
$query->update($db->quoteName('#__ucm_base'))
->set($db->quoteName('ucm_item_id') .
' = ' .
$db->quote($this->core_content_item_id))
->set($db->quoteName('ucm_type_id') .
' = ' .
$db->quote($this->core_type_id))
->set($db->quoteName('ucm_language_id') .
' = ' .
$db->quote($languageId))
->where($db->quoteName('ucm_id') .
' = ' .
$db->quote($this->core_content_id));
* Method to set the publishing state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
* @param mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
* @param integer $userId The user id of the user performing the operation.
* @return boolean True on success.
public function publish($pks =
null, $state =
1, $userId =
0)
// If there are no primary keys set check to see if the instance key is set.
// Nothing to set publishing state on, return false.
// Get the JDatabaseQuery object
$query =
$this->_db->getQuery(true);
// Update the publishing state for rows with the given primary keys.
$query->update($this->_db->quoteName($this->_tbl))
->set($this->_db->quoteName('core_state') .
' = ' . (int)
$state)
->where($this->_db->quoteName($k) .
'IN (' .
$pksImploded .
')');
// Determine if there is checkin support for the table.
$query->where(' (' .
$this->_db->quoteName('core_checked_out_user_id') .
' = 0 OR ' .
$this->_db->quoteName('core_checked_out_user_id') .
' = ' . (int)
$userId .
')');
$this->_db->setQuery($query);
catch
(RuntimeException $e)
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin &&
(count($pks) ==
$this->_db->getAffectedRows()))
// If the JTable instance value is in the list of primary keys that were set, set the instance.
$this->core_state =
$state;
Documentation generated on Tue, 19 Nov 2013 14:57:37 +0100 by phpDocumentor 1.4.3