- md5
- f1888a7bcab24adc468754b993f0f198
- sha1
- 7b7be460d5262e6a2bea7b6d8b6afe839a336b44
- sha256
- 0ec5d889ce8c3735bdfa242d41a3d97fe2a9c5c14a63a0a0f228edceee62a530
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
<?php
/**
* @package Joomla.Administrator
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Administrator
* @subpackage com_newsfeeds
*/
class NewsfeedsTableNewsfeed extends JTable
{
/**
* Helper object for storing and deleting tag information.
*
* @var JHelperTags
* @since 3.1
*/
protected $tagsHelper = null;
/**
* Constructor
*
* @param JDatabaseDriver A database connector object
*/
public function __construct(&$db)
{
parent::__construct('#__newsfeeds', 'id', $db);
$this->tagsHelper = new JHelperTags();
$this->tagsHelper->typeAlias = 'com_newsfeeds.newsfeed';
}
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new JRegistry;
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata']))
{
$registry = new JRegistry;
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (isset($array['images']) && is_array($array['images']))
{
$registry = new JRegistry;
$registry->loadArray($array['images']);
$array['images'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*/
public function check()
{
// Check for valid name.
if (trim($this->name) == '')
{
$this->setError(JText::_('COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME'));
return false;
}
if (empty($this->alias))
{
$this->alias = $this->name;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
// Check the publish down date is not earlier than publish up.
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up)
{
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
// 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
$bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters
$keys = explode(',', $after_clean); // create array using commas as delimiter
$clean_keys = array();
foreach ($keys as $key)
{
if (trim($key)) { // ignore blank keywords
$clean_keys[] = trim($key);
}
}
$this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", "
}
// clean up description -- eliminate quotes and <> brackets
if (!empty($this->metadesc))
{
// only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
}
return true;
}
/**
* Override parent delete method to delete tags information.
*
* @param integer $pk Primary key to delete.
*
* @return boolean True on success.
*
* @since 3.1
* @throws UnexpectedValueException
*/
public function delete($pk = null)
{
$result = parent::delete($pk);
$this->tagsHelper->typeAlias = 'com_newsfeeds.newsfeed';
return $result && $this->tagsHelper->deleteTagData($this, $pk);
}
/**
* Overriden JTable::store to set modified data.
*
* @param boolean True to update fields even if they are null.
* @return boolean True on success.
* @since 1.6
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id)
{
// Existing item
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
}
else
{
// New newsfeed. A feed 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
$table = JTable::getInstance('Newsfeed', 'NewsfeedsTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('COM_NEWSFEEDS_ERROR_UNIQUE_ALIAS'));
return false;
}
$this->tagsHelper->typeAlias = 'com_newsfeeds.newsfeed';
$this->tagsHelper->preStoreProcess($this);
$result = parent::store($updateNulls);
return $result && $this->tagsHelper->postStoreProcess($this);
}
}
The same content is in 2 releases, Joomla 3.1.0 to 3.1.1. See them all, or every version of this file.