Source for file newsfeed.php

Documentation is available at newsfeed.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_newsfeeds
  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. /**
  13.  * @package     Joomla.Administrator
  14.  * @subpackage  com_newsfeeds
  15.  */
  16. {
  17.     /**
  18.      * Constructor
  19.      *
  20.      * @param   JDatabaseDriver  &$db  A database connector object
  21.      */
  22.     public function __construct(&$db)
  23.     {
  24.         parent::__construct('#__newsfeeds''id'$db);
  25.     }
  26.  
  27.     /**
  28.      * Overloaded bind function to pre-process the params.
  29.      *
  30.      * @param   mixed  $array   An associative array or object to bind to the JTable instance.
  31.      * @param   mixed  $ignore  An optional array or space separated list of properties to ignore while binding.
  32.      *
  33.      * @return  boolean  True on success.
  34.      *
  35.      * @see     JTable:bind
  36.      * @since   1.5
  37.      */
  38.     public function bind($array$ignore '')
  39.     {
  40.         if (isset($array['params']&& is_array($array['params']))
  41.         {
  42.             $registry new JRegistry;
  43.             $registry->loadArray($array['params']);
  44.             $array['params'= (string) $registry;
  45.         }
  46.  
  47.         if (isset($array['metadata']&& is_array($array['metadata']))
  48.         {
  49.             $registry new JRegistry;
  50.             $registry->loadArray($array['metadata']);
  51.             $array['metadata'= (string) $registry;
  52.         }
  53.  
  54.         if (isset($array['images']&& is_array($array['images']))
  55.         {
  56.             $registry new JRegistry;
  57.             $registry->loadArray($array['images']);
  58.             $array['images'= (string) $registry;
  59.         }
  60.  
  61.         return parent::bind($array$ignore);
  62.     }
  63.  
  64.     /**
  65.      * Overloaded check method to ensure data integrity.
  66.      *
  67.      * @return  boolean  True on success.
  68.      */
  69.     public function check()
  70.     {
  71.         // Check for valid name.
  72.         if (trim($this->name== '')
  73.         {
  74.             $this->setError(JText::_('COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME'));
  75.             return false;
  76.         }
  77.  
  78.         if (empty($this->alias))
  79.         {
  80.             $this->alias $this->name;
  81.         }
  82.         $this->alias JApplication::stringURLSafe($this->alias);
  83.         if (trim(str_replace('-'''$this->alias)) == '')
  84.         {
  85.             $this->alias JFactory::getDate()->format("Y-m-d-H-i-s");
  86.         }
  87.  
  88.         // Check the publish down date is not earlier than publish up.
  89.         if ((int) $this->publish_down && $this->publish_down $this->publish_up)
  90.         {
  91.             $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
  92.             return false;
  93.         }
  94.  
  95.         // clean up keywords -- eliminate extra spaces between phrases
  96.         // and cr (\r) and lf (\n) characters from string
  97.         if (!empty($this->metakey))
  98.         {
  99.             // only process if not empty
  100.             $bad_characters array("\n""\r""\"""<"">")// array of characters to remove
  101.             $after_clean JString::str_ireplace($bad_characters""$this->metakey)// remove bad characters
  102.             $keys explode(','$after_clean)// create array using commas as delimiter
  103.             $clean_keys array();
  104.  
  105.             foreach ($keys as $key)
  106.             {
  107.                 if (trim($key)) {  // ignore blank keywords
  108.                     $clean_keys[trim($key);
  109.                 }
  110.             }
  111.             $this->metakey implode(", "$clean_keys)// put array back together delimited by ", "
  112.         }
  113.  
  114.         // clean up description -- eliminate quotes and <> brackets
  115.         if (!empty($this->metadesc))
  116.         {
  117.             // only process if not empty
  118.             $bad_characters array("\"""<"">");
  119.             $this->metadesc JString::str_ireplace($bad_characters""$this->metadesc);
  120.         }
  121.  
  122.         return true;
  123.     }
  124.  
  125.     /**
  126.      * Overriden JTable::store to set modified data.
  127.      *
  128.      * @param   boolean     $updateNulls  True to update fields even if they are null.
  129.      *
  130.      * @return  boolean  True on success.
  131.      *
  132.      * @since   1.6
  133.      */
  134.     public function store($updateNulls false)
  135.     {
  136.         $date    JFactory::getDate();
  137.         $user    JFactory::getUser();
  138.         if ($this->id)
  139.         {
  140.             // Existing item
  141.             $this->modified        $date->toSql();
  142.             $this->modified_by    $user->get('id');
  143.         }
  144.         else
  145.         {
  146.             // New newsfeed. A feed created and created_by field can be set by the user,
  147.             // so we don't touch either of these if they are set.
  148.             if (!(int) $this->created)
  149.             {
  150.                 $this->created $date->toSql();
  151.             }
  152.             if (empty($this->created_by))
  153.             {
  154.                 $this->created_by $user->get('id');
  155.             }
  156.         }
  157.         // Verify that the alias is unique
  158.         $table JTable::getInstance('Newsfeed''NewsfeedsTable');
  159.         if ($table->load(array('alias' => $this->alias'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
  160.         {
  161.             $this->setError(JText::_('COM_NEWSFEEDS_ERROR_UNIQUE_ALIAS'));
  162.             return false;
  163.         }
  164.  
  165.         // Save links as punycode.
  166.         $this->link JStringPunycode::urlToPunycode($this->link);
  167.  
  168.         return parent::store($updateNulls);
  169.     }
  170. }

Documentation generated on Tue, 19 Nov 2013 15:09:27 +0100 by phpDocumentor 1.4.3