[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_weblinks/tables/ -> weblink.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: weblink.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @subpackage    Weblinks
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // no direct access
  16  defined('_JEXEC') or die('Restricted access');
  17  
  18  /**
  19  * Weblink Table class
  20  *
  21  * @package        Joomla
  22  * @subpackage    Weblinks
  23  * @since 1.0
  24  */
  25  class TableWeblink extends JTable
  26  {
  27      /**
  28       * Primary Key
  29       *
  30       * @var int
  31       */
  32      var $id = null;
  33  
  34      /**
  35       * @var int
  36       */
  37      var $catid = null;
  38  
  39      /**
  40       * @var int
  41       */
  42      var $sid = null;
  43  
  44      /**
  45       * @var string
  46       */
  47      var $title = null;
  48  
  49      /**
  50       * @var string
  51       */
  52      var $alias = null;
  53  
  54      /**
  55       * @var string
  56       */
  57      var $url = null;
  58  
  59      /**
  60       * @var string
  61       */
  62      var $description = null;
  63  
  64      /**
  65       * @var datetime
  66       */
  67      var $date = null;
  68  
  69      /**
  70       * @var int
  71       */
  72      var $hits = null;
  73  
  74      /**
  75       * @var int
  76       */
  77      var $published = null;
  78  
  79      /**
  80       * @var boolean
  81       */
  82      var $checked_out = 0;
  83  
  84      /**
  85       * @var time
  86       */
  87      var $checked_out_time = 0;
  88  
  89      /**
  90       * @var int
  91       */
  92      var $ordering = null;
  93  
  94      /**
  95       * @var int
  96       */
  97      var $archived = null;
  98  
  99      /**
 100       * @var int
 101       */
 102      var $approved = null;
 103  
 104      /**
 105       * @var string
 106       */
 107      var $params = null;
 108  
 109      /**
 110       * Constructor
 111       *
 112       * @param object Database connector object
 113       * @since 1.0
 114       */
 115  	function __construct(& $db) {
 116          parent::__construct('#__weblinks', 'id', $db);
 117      }
 118  
 119      /**
 120      * Overloaded bind function
 121      *
 122      * @acces public
 123      * @param array $hash named array
 124      * @return null|string    null is operation was satisfactory, otherwise returns an error
 125      * @see JTable:bind
 126      * @since 1.5
 127      */
 128  	function bind($array, $ignore = '')
 129      {
 130          if (key_exists( 'params', $array ) && is_array( $array['params'] ))
 131          {
 132              $registry = new JRegistry();
 133              $registry->loadArray($array['params']);
 134              $array['params'] = $registry->toString();
 135          }
 136  
 137          return parent::bind($array, $ignore);
 138      }
 139  
 140      /**
 141       * Overloaded check method to ensure data integrity
 142       *
 143       * @access public
 144       * @return boolean True on success
 145       * @since 1.0
 146       */
 147  	function check()
 148      {
 149          if (JFilterInput::checkAttribute(array ('href', $this->url))) {
 150              $this->setError( JText::_('Please provide a valid URL'));
 151              return false;
 152          }
 153  
 154          //Remove all HTML tags from the title and description
 155          $filter = new JFilterInput(array(), array(), 0, 0);
 156          $this->description = $filter->clean($this->description);
 157          $this->title = $filter->clean($this->title);
 158  
 159          /** check for valid name */
 160          if (trim($this->title) == '') {
 161              $this->setError(JText::_('Your Weblink must contain a title.'));
 162              return false;
 163          }
 164  
 165          if (!(preg_match('#http://#i', $this->url) || (preg_match('#https://#i', $this->url)) || (preg_match('#ftp://#i', $this->url)))) {
 166              $this->url = 'http://'.$this->url;
 167          }
 168  
 169          /** check for existing name */
 170          $query = 'SELECT id FROM #__weblinks WHERE title = '.$this->_db->Quote($this->title).' AND catid = '.(int) $this->catid;
 171          $this->_db->setQuery($query);
 172  
 173          $xid = intval($this->_db->loadResult());
 174          if ($xid && $xid != intval($this->id)) {
 175              $this->setError(JText::sprintf('WARNNAMETRYAGAIN', JText::_('Web Link')));
 176              return false;
 177          }
 178  
 179          if(empty($this->alias)) {
 180              $this->alias = $this->title;
 181          }
 182          $this->alias = JFilterOutput::stringURLSafe($this->alias);
 183          if(trim(str_replace('-','',$this->alias)) == '') {
 184              $datenow =& JFactory::getDate();
 185              $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
 186          }
 187  
 188          return true;
 189      }
 190  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1