CoreFiles by mySites.guru
weblink.php112 lines, 2,304 bytes, from Joomla_3.0.4-Stable-Full_Package.zip
Raw History Compare with 3.0.3
md5
dd953c42fb4f54406dbb5d2c7d8e0441
sha1
15b534442ad967fa5ebefcfb283531e71752c9d5
sha256
403395256d77b22140087b1a4bb2d8456e8d5419e3c2a4032e18974df95f38da
<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_weblinks
 *
 * @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;

/**
 * Weblinks Component Model for a Weblink record
 *
 * @package     Joomla.Site
 * @subpackage  com_weblinks
 * @since       1.5
 */
class WeblinksModelWeblink extends JModelItem
{
	/**
	 * Model context string.
	 *
	 * @access	protected
	 * @var		string
	 */
	protected $_context = 'com_weblinks.weblink';

	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @since   1.6
	 */
	protected function populateState()
	{
		$app = JFactory::getApplication();
		$params	= $app->getParams();

		// Load the object state.
		$id	= $app->input->getInt('id');
		$this->setState('weblink.id', $id);

		// Load the parameters.
		$this->setState('params', $params);
	}

	/**
	 * Method to get an object.
	 *
	 * @param   integer	The id of the object to get.
	 *
	 * @return  mixed  Object on success, false on failure.
	 */
	public function &getItem($id = null)
	{
		if ($this->_item === null)
		{
			$this->_item = false;

			if (empty($id))
			{
				$id = $this->getState('weblink.id');
			}

			// Get a level row instance.
			$table = JTable::getInstance('Weblink', 'WeblinksTable');

			// Attempt to load the row.
			if ($table->load($id))
			{
				// Check published state.
				if ($published = $this->getState('filter.published'))
				{
					if ($table->state != $published)
					{
						return $this->_item;
					}
				}

				// Convert the JTable to a clean JObject.
				$properties = $table->getProperties(1);
				$this->_item = JArrayHelper::toObject($properties, 'JObject');
			}
			elseif ($error = $table->getError())
			{
				$this->setError($error);
			}
		}

		return $this->_item;
	}

	/**
	 * Method to increment the hit counter for the weblink
	 *
	 * @param   integer  $id  Optional ID of the weblink.
	 *
	 * @return  boolean  True on success
	 */
	public function hit($id = null)
	{
		if (empty($id))
		{
			$id = $this->getState('weblink.id');
		}

		$weblink = $this->getTable('Weblink', 'WeblinksTable');
		return $weblink->hit($id);
	}
}

The same content is in 2 releases, Joomla 3.0.3 to 3.0.4. See them all, or every version of this file.