Пример #1
0
 /**
  * Validate a slug
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		4.0
  */
 private function _validateSlug()
 {
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     // Create the slug
     $this->slug = Com_virtuemart::createSlug($this->category_name);
     // Check if the slug exists
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('COUNT(' . $db->Quote($this->_tbl_key) . ')');
     $query->from($this->_tbl);
     $query->where($db->quoteName('slug') . ' = ' . $db->Quote($this->slug));
     $db->setQuery($query);
     $slugs = $db->loadResult();
     $csvilog->addDebug(JText::_('COM_CSVI_CHECK_CATGEGORY_SLUG'), true);
     if ($slugs > 0) {
         $jdate = JFactory::getDate();
         $this->slug .= $jdate->format("Y-m-d-h-i-s") . mt_rand();
     }
 }
 /**
  * Create a slug if needed and store the product
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		4.0
  */
 public function store()
 {
     if (empty(${$this}->_tbl_key)) {
         // Create the slug
         $this->slug = Com_virtuemart::createSlug($this->mf_category_name);
     }
     return parent::store();
 }
Пример #3
0
 /**
  * Validate a slug
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		4.0
  */
 public function createSlug()
 {
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     // Create the slug
     $this->slug = Com_virtuemart::createSlug($this->product_name);
     // Check if the slug exists
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('COUNT(' . $db->qn($this->_tbl_key) . ')')->from($this->_tbl)->where($db->qn('slug') . ' = ' . $db->q($this->slug))->where($db->qn($this->_tbl_key) . ' != ' . $db->q($this->virtuemart_product_id));
     $db->setQuery($query);
     $slugs = $db->loadResult();
     $csvilog->addDebug(JText::_('COM_CSVI_CHECK_PRODUCT_SLUG'), true);
     if ($slugs > 0) {
         $jdate = JFactory::getDate();
         $this->slug .= $jdate->format("Y-m-d-h-i-s") . mt_rand();
     }
 }