Пример #1
0
 /**
  * Overloaded check function
  * @since	3.4.0
  */
 public function check()
 {
     // Import Joomla 2.5
     jimport('joomla.filter.output');
     // If there is an ordering column and this is a new row then get the next ordering value
     if (property_exists($this, 'ordering') && $this->id == 0) {
         $this->ordering = self::getNextOrder();
     }
     // URL alias
     if (empty($this->alias)) {
         $this->alias = $this->title;
     }
     $this->alias = JFilterOutput::stringURLSafe($this->alias);
     // Alias is not generated if non-latin characters, so we fix it by using created date, or title if unicode is activated, as alias
     if ($this->alias == null || empty($this->alias)) {
         if (JFactory::getConfig()->get('unicodeslugs') == 1) {
             $this->alias = JFilterOutput::stringURLUnicodeSlug($this->title);
         } else {
             $this->alias = JFilterOutput::stringURLSafe($this->created);
         }
     }
     // Slug auto-create
     $slug_empty = empty($this->slug) ? true : false;
     if ($slug_empty) {
         $this->slug = $this->title;
     }
     $this->slug = iCFilterOutput::stringToSlug($this->slug);
     // Slug is not generated if non-latin characters, so we fix it by using created date as a slug
     if ($this->slug == null) {
         $this->slug = iCFilterOutput::stringToSlug($this->created);
     }
     // Check if Slug already exists
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('slug')->from($db->qn('#__icagenda_customfields'))->where($db->qn('slug') . ' = ' . $db->q($this->slug));
     if (!empty($this->id)) {
         $query->where('id <> ' . (int) $this->id);
     }
     $db->setQuery($query);
     $slug_exists = $db->loadResult();
     if ($slug_exists) {
         $error_slug = $slug_empty ? JText::sprintf('COM_ICAGENDA_CUSTOMFIELD_DATABASE_ERROR_AUTO_SLUG', '<strong>' . $this->title . '</strong>', '<strong>' . $this->slug . '</strong>') : '<strong>' . JText::_('COM_ICAGENDA_CUSTOMFIELD_DATABASE_ERROR_UNIQUE_SLUG') . '</strong>';
         $this->setError($error_slug . '<br /><br /><span class="iCicon-info-circle"></span> <i>' . JTEXT::_('COM_ICAGENDA_CUSTOMFIELD_SLUG_DESC') . '</i>');
         return false;
     }
     return parent::check();
 }