Source for file weblink.php

Documentation is available at weblink.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_weblinks
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR '/tables');
  13.  
  14. /**
  15.  * Weblinks Component Model for a Weblink record
  16.  *
  17.  * @package     Joomla.Site
  18.  * @subpackage  com_weblinks
  19.  * @since       1.5
  20.  */
  21. {
  22.     /**
  23.      * Model context string.
  24.      *
  25.      * @access    protected
  26.      * @var        string 
  27.      */
  28.     protected $_context = 'com_weblinks.weblink';
  29.  
  30.     /**
  31.      * Method to auto-populate the model state.
  32.      *
  33.      * Note. Calling getState in this method will result in recursion.
  34.      *
  35.      * @since   1.6
  36.      */
  37.     protected function populateState()
  38.     {
  39.         $app JFactory::getApplication();
  40.         $params    $app->getParams();
  41.  
  42.         // Load the object state.
  43.         $id    $app->input->getInt('id');
  44.         $this->setState('weblink.id'$id);
  45.  
  46.         // Load the parameters.
  47.         $this->setState('params'$params);
  48.     }
  49.  
  50.     /**
  51.      * Method to get an object.
  52.      *
  53.      * @param   integer    The id of the object to get.
  54.      *
  55.      * @return  mixed  Object on success, false on failure.
  56.      */
  57.     public function getItem($id null)
  58.     {
  59.         if ($this->_item === null)
  60.         {
  61.             $this->_item = false;
  62.  
  63.             if (empty($id))
  64.             {
  65.                 $id $this->getState('weblink.id');
  66.             }
  67.  
  68.             // Get a level row instance.
  69.             $table JTable::getInstance('Weblink''WeblinksTable');
  70.  
  71.             // Attempt to load the row.
  72.             if ($table->load($id))
  73.             {
  74.                 // Check published state.
  75.                 if ($published $this->getState('filter.published'))
  76.                 {
  77.                     if ($table->state != $published)
  78.                     {
  79.                         return $this->_item;
  80.                     }
  81.                 }
  82.  
  83.                 // Convert the JTable to a clean JObject.
  84.                 $properties $table->getProperties(1);
  85.                 $this->_item = JArrayHelper::toObject($properties'JObject');
  86.             }
  87.             elseif ($error $table->getError())
  88.             {
  89.                 $this->setError($error);
  90.             }
  91.         }
  92.  
  93.         return $this->_item;
  94.     }
  95.  
  96.     /**
  97.      * Returns a reference to the a Table object, always creating it.
  98.      *
  99.      * @param    type    The table type to instantiate
  100.      * @param    string    A prefix for the table class name. Optional.
  101.      * @param    array    Configuration array for model. Optional.
  102.      * @return    JTable    A database object
  103.      * @since    1.6
  104.      */
  105.     public function getTable($type 'Weblink'$prefix 'WeblinksTable'$config array())
  106.     {
  107.         return JTable::getInstance($type$prefix$config);
  108.     }
  109.  
  110.     /**
  111.      * Method to increment the hit counter for the weblink
  112.      *
  113.      * @param   integer  $id  Optional ID of the weblink.
  114.      *
  115.      * @return  boolean  True on success
  116.      */
  117.     public function hit($id null)
  118.     {
  119.         if (empty($id))
  120.         {
  121.             $id $this->getState('weblink.id');
  122.         }
  123.  
  124.         $weblink $this->getTable('Weblink''WeblinksTable');
  125.         return $weblink->hit($id);
  126.     }
  127. }

Documentation generated on Tue, 19 Nov 2013 15:18:24 +0100 by phpDocumentor 1.4.3