public static function getPermalink($title) { $permalink = EasyBlogRouter::generatePermalink($title); // Make sure no such permalink exists. $originalSlug = $permalink; $i = 1; while (EasyBlogRouter::_isBlogPermalinkExists($permalink)) { $permalink = $originalSlug . '-' . $i; $i++; } return $permalink; }
public static function getBloggerPermalink($id) { $config = EasyBlogHelper::getConfig(); JTable::addIncludePath(EBLOG_TABLES); if ($id == 0) { $id = null; } $user = JFactory::getUser($id); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($id); $profile->setUser($user); if (empty($user->username)) { // blogger not exists return JText::_('COM_EASYBLOG_INVALID_PERMALINK_BLOGGER'); } $bloggerPermalink = $profile->permalink; if (empty($bloggerPermalink)) { $bloggerPermalink = EasyBlogRouter::generatePermalink($user->username); $db = EasyBlogHelper::db(); $query = 'UPDATE `#__easyblog_users` SET `permalink` =' . $db->Quote($bloggerPermalink) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('id') . '=' . $db->Quote($profile->id); $db->setQuery($query); $db->query(); } if ($config->get('main_sef_unicode')) { return $profile->id . '-' . $bloggerPermalink; } else { return $bloggerPermalink; } }
/** * Must only be bind when using POST data **/ function bind($data, $post = false) { parent::bind($data); if ($post) { $acl = EasyBlogACLHelper::getRuleSet(); $my = JFactory::getUser(); // Some properties needs to be overriden. $content = JRequest::getVar('write_content_hidden', '', 'post', 'string', JREQUEST_ALLOWRAW); if ($this->id == 0) { // this is to check if superadmin assign blog author during blog creation. if (empty($this->created_by)) { $this->created_by = $my->id; } } //remove unclean editor code. $pattern = array('/<p><br _mce_bogus="1"><\\/p>/i', '/<p><br mce_bogus="1"><\\/p>/i', '/<br _mce_bogus="1">/i', '/<br mce_bogus="1">/i', '/<p><br><\\/p>/i'); $replace = array('', '', '', '', ''); $content = preg_replace($pattern, $replace, $content); // Search for readmore tags using Joomla's mechanism $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i'; $pos = preg_match($pattern, $content); if ($pos == 0) { $this->intro = $content; // @rule: Since someone might update this post, we need to clear out the content // if it doesn't contain anything. $this->content = ''; } else { list($intro, $main) = preg_split($pattern, $content, 2); $this->intro = $intro; $this->content = $main; } $publish_up = ''; $publish_down = ''; $created_date = ''; $tzoffset = EasyBlogDateHelper::getOffSet(); if (!empty($this->created)) { $date = EasyBlogHelper::getDate($this->created, $tzoffset); $created_date = $date->toMySQL(); } if ($this->publish_down == '0000-00-00 00:00:00') { $publish_down = $this->publish_down; } else { if (!empty($this->publish_down)) { $date = EasyBlogHelper::getDate($this->publish_down, $tzoffset); $publish_down = $date->toMySQL(); } } if (!empty($this->publish_up)) { $date = EasyBlogHelper::getDate($this->publish_up, $tzoffset); $publish_up = $date->toMySQL(); } //default joomla date obj $date = EasyBlogHelper::getDate(); $this->created = !empty($created_date) ? $created_date : $date->toMySQL(); $this->modified = $date->toMySQL(); $this->publish_up = !empty($publish_up) ? $publish_up : $date->toMySQL(); $this->publish_down = empty($publish_down) ? '0000-00-00 00:00:00' : $publish_down; $this->ispending = empty($acl->rules->publish_entry) ? 1 : 0; $this->title = trim($this->title); $i = 1; while ($this->aliasExists() || empty($this->permalink)) { $this->permalink = empty($this->permalink) ? $this->title : $this->permalink . '-' . $i; $i++; } $this->permalink = EasyBlogRouter::generatePermalink($this->permalink); } return true; }
/** * Overrides parent's bind method to add our own logic. * * @param Array $data **/ function bind($data, $ignore = array()) { parent::bind($data, $ignore); if (empty($this->created)) { $this->created = EasyBlogHelper::getDate()->toMySQL(); } jimport('joomla.filesystem.filter.filteroutput'); $i = 1; while ($this->aliasExists() || empty($this->alias)) { $this->alias = empty($this->alias) ? $this->title : $this->alias . '-' . $i; $i++; } //$this->alias = JFilterOutput::stringURLSafe( $this->alias ); $this->alias = EasyBlogRouter::generatePermalink($this->alias); }
public function store($updateNulls = false) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // @rule: Check for empty title if (empty($this->title)) { $this->setError(JText::_('COM_EASYBLOG_INVALID_TAG')); return false; } // @rule: Check if such tag exists. if ($this->exists($this->title, !$this->id)) { $this->setError(JText::_('COM_EASYBLOG_TAG_ALREADY_EXISTS')); return false; } // @task: If alias is null, we need to generate them here. jimport('joomla.filesystem.filter.filteroutput'); $i = 1; while ($this->aliasExists() || empty($this->alias)) { $this->alias = empty($this->alias) ? $this->title : $this->alias . '-' . $i; $i++; } $this->alias = EasyBlogRouter::generatePermalink($this->alias); if (!empty($this->created)) { $offset = EasyBlogDateHelper::getOffSet(); $newDate = EasyBlogHelper::getDate($this->created, $offset); $this->created = $newDate->toMySQL(); } else { $newDate = EasyBlogHelper::getDate(); $this->created = $newDate->toMySQL(); } $isNew = !$this->id; $state = parent::store(); $my = JFactory::getUser(); if ($isNew && $my->id != 0) { JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); $config = EasyBlogHelper::getConfig(); // @rule: Integrations with EasyDiscuss EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.new.tag', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_TAG', $this->title)); EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.new.tag', $my->id); EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.new.tag', $my->id); // Assign EasySocial points $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->assignPoints('tag.create', $my->id); if ($config->get('main_jomsocial_userpoint')) { $jsUserPoint = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php'; if (JFile::exists($jsUserPoint)) { require_once $jsUserPoint; CUserPoints::assignPoint('com_easyblog.tag.add', $my->id); } } // AlphaUserPoints // since 1.2 if (EasyBlogHelper::isAUPEnabled()) { AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_tag', '', 'easyblog_add_tag_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_TAG_ADDED', $this->title)); } } if ($state) { //activity logging. $activity = new stdClass(); $activity->actor_id = $my->id; $activity->target_id = '0'; $activity->context_type = 'tag'; $activity->context_id = $this->id; $activity->verb = $isNew ? 'add' : 'update'; $activity->uuid = $this->title; EasyBlogHelper::activityLog($activity); } return $state; }