Source for file content.php
Documentation is available at content.php
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @deprecated Class will be removed upon completion of transition to UCM
* @param JDatabaseDriver $db A database connector object
* This is left here for reference:
* This would set up the tags observer in $this from here (so not entirely decoupled):
* JTableObserverTags::createObserver($this, array('typeAlias' => 'com_content.article'));
* But this makes the relation between content and tags completely external to Content as JTable is observable:
* So we are doing this only once in libraries/cms.php:
* JObserverFactory::addObserverClassToClass('JTableObserverTags', 'JTableContent', array('typeAlias' => 'com_content.article'));
* Method to compute the default name of the asset.
* The default name is in the form table_name.id
* where id is the value of the primary key of the table.
return 'com_content.article.' . (int)
$this->$k;
* Method to return the title to use for the asset table.
* Method to get the parent asset id for the record
* @param JTable $table A JTable object (optional) for the asset parent
* @param integer $id The id (optional) of the content.
// This is a article under a category.
// Build the query to get the asset id for the parent category.
$query =
$this->_db->getQuery(true)
->select($this->_db->quoteName('asset_id'))
->from($this->_db->quoteName('#__categories'))
->where($this->_db->quoteName('id') .
' = ' . (int)
$this->catid);
// Get the asset id from the database.
$this->_db->setQuery($query);
if ($result =
$this->_db->loadResult())
$assetId = (int)
$result;
* 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 =
'')
// Search for the {readmore} tag and split the text up accordingly.
if (isset
($array['articletext']))
$pattern =
'#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
$tagPos =
preg_match($pattern, $array['articletext']);
$this->introtext =
$array['articletext'];
list
($this->introtext, $this->fulltext) =
preg_split($pattern, $array['articletext'], 2);
if (isset
($array['attribs']) &&
is_array($array['attribs']))
$registry->loadArray($array['attribs']);
$array['attribs'] = (string)
$registry;
if (isset
($array['metadata']) &&
is_array($array['metadata']))
$registry->loadArray($array['metadata']);
$array['metadata'] = (string)
$registry;
if (isset
($array['rules']) &&
is_array($array['rules']))
return parent::bind($array, $ignore);
* Overloaded check function
* @return boolean True on success, false on failure
if (trim($this->title) ==
'')
if (trim($this->alias) ==
'')
$this->alias =
$this->title;
// Check the publish down date is not earlier than publish up.
if ($this->publish_down >
$this->_db->getNullDate() &&
$this->publish_down <
$this->publish_up)
$temp =
$this->publish_up;
$this->publish_up =
$this->publish_down;
$this->publish_down =
$temp;
// Clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->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->metakey =
implode(", ", $clean_keys);
* 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)
$this->modified =
$date->toSql();
$this->modified_by =
$user->get('id');
// New article. An article created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int)
$this->created)
$this->created =
$date->toSql();
if (empty($this->created_by))
$this->created_by =
$user->get('id');
// Verify that the alias is unique
if ($table->load(array('alias' =>
$this->alias, 'catid' =>
$this->catid)) &&
($table->id !=
$this->id ||
$this->id ==
0))
$this->setError(JText::_('JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS'));
return parent::store($updateNulls);
* 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.
// Build the WHERE clause for the primary keys.
$where =
$k .
'=' .
implode(' OR ' .
$k .
'=', $pks);
// Determine if there is checkin support for the table.
$checkin =
' AND (checked_out = 0 OR checked_out = ' . (int)
$userId .
')';
// Update the publishing state for rows with the given primary keys.
$query =
$this->_db->getQuery(true)
->update($this->_db->quoteName($this->_tbl))
->set($this->_db->quoteName('state') .
' = ' . (int)
$state)
->where('(' .
$where .
')' .
$checkin);
$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.
Documentation generated on Tue, 19 Nov 2013 14:56:52 +0100 by phpDocumentor 1.4.3