本文整理汇总了PHP中DiscussHelper类的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper类的具体用法?PHP DiscussHelper怎么用?PHP DiscussHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DiscussHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace
public static function replace($tmp, $text)
{
$config = DiscussHelper::getConfig();
$pattern = '@(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))@';
preg_match_all($pattern, $tmp, $matches);
$targetBlank = $config->get('main_link_new_window') ? ' target="_blank"' : '';
if (!isset($matches[0]) || !is_array($matches[0])) {
return;
}
// to avoid infinite loop, unique the matches
$links = $matches[0];
foreach ($links as &$link) {
$link = JString::strtolower($link);
}
$uniques = array_unique($links);
foreach ($uniques as $match) {
$matchProtocol = $match;
if (stristr($matchProtocol, 'http://') === false && stristr($matchProtocol, 'https://') === false && stristr($matchProtocol, 'ftp://') === false) {
$matchProtocol = 'http://' . $matchProtocol;
}
$text = JString::str_ireplace($match, '<a href="' . $matchProtocol . '"' . $targetBlank . '>' . $match . '</a>', $text);
}
$text = JString::str_ireplace('"', '"', $text);
return $text;
}
示例2: display
function display($tmpl = null)
{
$document = JFactory::getDocument();
$config = DiscussHelper::getConfig();
$doc = JFactory::getDocument();
DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_MEMBERS_TITLE'));
$this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_MEMBERS'));
$model = $this->getModel('Users');
$userQuery = JRequest::getString('userQuery', '');
$result = $model->getData($userQuery);
$pagination = $model->getPagination();
$sort = JRequest::getString('sort', 'latest');
$filteractive = JRequest::getString('filter', 'allposts');
$users = DiscussHelper::formatUsers($result);
$sort = JRequest::getCmd('sort', 'name');
$uids = $config->get('main_exclude_members');
if (!empty($uids)) {
// Remove white space
$uids = str_replace(' ', '', $uids);
$excludeId = explode(',', $uids);
$temp = array();
foreach ($users as $user) {
if (!in_array($user->id, $excludeId)) {
$temp[] = $user;
}
}
$users = $temp;
}
$theme = new DiscussThemes();
$theme->set('users', $users);
$theme->set('pagination', $pagination);
$theme->set('sort', $sort);
$theme->set('userQuery', $userQuery);
echo $theme->fetch('users.php');
}
示例3: history
/**
* Displays the user's points achievement history
*
* @since 2.0
* @access public
*/
public function history($tmpl = null)
{
$app = JFactory::getApplication();
$id = JRequest::getInt('id');
if (!$id) {
DiscussHelper::setMessageQueue(JText::_('Unable to locate the id of the user.'), DISCUSS_QUEUE_ERROR);
$app->redirect('index.php?option=com_easydiscuss');
$app->close();
}
$model = DiscussHelper::getModel('Points', true);
$history = $model->getPointsHistory($id);
foreach ($history as $item) {
$date = DiscussDateHelper::dateWithOffSet($item->created);
$item->created = $date->toFormat('%A, %b %e %Y');
$points = DiscussHelper::getHelper('Points')->getPoints($item->command);
if ($points) {
if ($points[0]->rule_limit < 0) {
$item->class = 'badge-important';
$item->points = $points[0]->rule_limit;
} else {
$item->class = 'badge-info';
$item->points = '+' . $points[0]->rule_limit;
}
} else {
$item->class = 'badge-info';
$item->points = '+';
}
}
$theme = new DiscussThemes();
$theme->set('history', $history);
echo $theme->fetch('points.history.php');
}
示例4: store
public function store($updateNulls = false)
{
if (empty($this->created) || $this->created == '0000-00-00 00:00:00') {
$this->created = DiscussHelper::getDate()->toMySQL();
}
return parent::store();
}
示例5: process
function process()
{
$view = new EasyDiscussView();
$date = DiscussHelper::getDate();
$now = $date->toMySQL();
$modelSubscribe = $view->getModel('Subscribe');
$subscribers = $modelSubscribe->getSiteSubscribers($this->interval, $now);
$total = count($subscribers);
if (empty($total)) {
return false;
}
foreach ($subscribers as $subscriber) {
$notify = DiscussHelper::getNotification();
$data = array();
$rows = $modelSubscribe->getCreatedPostByInterval($subscriber->sent_out, $now);
$posts = array();
if ($rows) {
foreach ($rows as $row) {
$row['categorylink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=categorie&layout=listings&category_id=' . $row['category_id'], false, true);
$row['link'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row['id'], false, true);
$row['userlink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=profile&id=' . $row['user_id'], false, true);
$category = DiscussHelper::getTable('Category');
$creator = DiscussHelper::getTable('Profile');
$category->load($row['category_id']);
$creator->load($row['user_id']);
$row['category'] = $category->getTitle();
$row['avatar'] = $creator->getAvatar();
$row['name'] = $creator->getName();
$row['date'] = DiscussDateHelper::toFormat($row['created'], '%b %e, %Y');
$row['message'] = DiscussHelper::parseContent($row['content']);
$posts[] = $row;
}
}
$data['post'] = $posts;
$data['total'] = count($data['post']);
$data['unsubscribeLink'] = DiscussHelper::getUnsubscribeLink($subscriber, true, true);
$subject = $date->toMySQL();
switch (strtoupper($this->interval)) {
case 'DAILY':
$subject = $date->toFormat('%F');
$data['interval'] = JText::_('today');
break;
case 'WEEKLY':
$subject = $date->toFormat('%V');
$data['interval'] = JText::_('this week');
break;
case 'MONTHLY':
$subject = $date->toFormat('%B');
$data['interval'] = JText::_('this month');
break;
}
if (!empty($data['post'])) {
$notify->addQueue($subscriber->email, JText::sprintf('COM_EASYDISCUSS_YOUR_' . $this->interval . '_SUBSCRIPTION', $subject), '', 'email.subscription.site.interval.php', $data);
}
$subscribe = DiscussHelper::getTable('Subscribe');
$subscribe->load($subscriber->id);
$subscribe->sent_out = $now;
$subscribe->store();
}
}
示例6: isLock
private static function isLock($post_id)
{
$db = DiscussHelper::getDBO();
$query = 'SELECT `islock` FROM `#__discuss_posts` WHERE `id` = ' . $db->quote($post_id);
$db->setQuery($query);
return $db->loadResult();
}
示例7: display
public function display($tpl = null)
{
// @rule: Test for user access if on 1.6 and above
if (DiscussHelper::getJoomlaVersion() >= '1.6') {
if (!JFactory::getUser()->authorise('discuss.manage.reports', 'com_easydiscuss')) {
JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
JFactory::getApplication()->close();
}
}
// Initialise variables
$mainframe = JFactory::getApplication();
$filter_state = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.filter_state', 'filter_state', '*', 'word');
$search = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.search', 'search', '', 'string');
$search = trim(JString::strtolower($search));
$order = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.filter_order', 'filter_order', 'a.id', 'cmd');
$orderDirection = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.filter_order_Dir', 'filter_order_Dir', '', 'word');
$reportModel = $this->getModel('reports');
$reports = $reportModel->getReports();
$pagination = $reportModel->getPagination();
$this->assignRef('reports', $reports);
$this->assignRef('pagination', $pagination);
$this->assign('state', $this->getFilterState($filter_state));
$this->assign('search', $search);
$this->assign('order', $order);
$this->assign('orderDirection', $orderDirection);
parent::display($tpl);
}
示例8: removeLocation
/**
* Remove a location from a post.
*
* @since 3.0
* @access public
*/
public function removeLocation($id)
{
$ajax = new Disjax();
$post = DiscussHelper::getTable('Post');
$state = $post->load($id);
$my = JFactory::getUser();
if (!$id || !$state) {
echo JText::_('COM_EASYDISCUSS_INVALID_ID');
return $ajax->send();
}
if ($post->user_id != $my->id && !DiscussHelper::isModerator($post->category_id)) {
echo JText::_('COM_EASYDISCUSS_NOT_ALLOWED_TO_REMOVE_LOCATION_FOR_POST');
return $ajax->send();
}
// Update the address, latitude and longitude of the post.
$post->address = '';
$post->latitude = '';
$post->longitude = '';
$post->store();
$content = JText::_('COM_EASYDISCUSS_LOCATION_IS_REMOVED');
$options = new stdClass();
$options->content = $content;
$options->title = JText::_('COM_EASYDISCUSS_DELETE_LOCATION_TITLE');
$buttons = array();
$button = new stdClass();
$button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
$button->action = 'disjax.closedlg();';
$buttons[] = $button;
$options->buttons = $buttons;
$ajax->script('discuss.location.removeHTML("' . $id . '");');
$ajax->dialog($options);
return $ajax->send();
}
示例9: getCustomFieldsAcl
public function getCustomFieldsAcl()
{
$db = DiscussHelper::getDBO();
$query = 'SELECT * FROM ' . $db->nameQuote('#__discuss_customfields_acl') . ' ORDER BY ' . $db->nameQuote('id');
$db->setQuery($query);
return $db->loadObjectList();
}
示例10: add
public static function add($userObj, $entityObj, $interval = null, $data)
{
if (!$userObj instanceof JUser) {
return false;
}
if ($entityObj instanceof DiscussPost) {
$type = 'post';
} elseif ($entityObj instanceof DiscussCategory) {
$type = 'category';
} else {
// $type = 'site'
return false;
}
$email = isset($data['poster_email']) ? $data['poster_email'] : '';
$name = isset($data['poster_name']) ? $data['poster_name'] : '';
$subscribe = DiscussHelper::getTable('Subscribe');
if (empty($userObj->id)) {
$subscribe->userid = 0;
$subscribe->member = 0;
$subscribe->email = $email;
$subscribe->fullname = $name;
} else {
$subscribe->userid = $userObj->id;
$subscribe->member = 1;
$subscribe->email = $userObj->email;
$subscribe->fullname = $userObj->name;
}
$subscribe->type = $type;
$subscribe->cid = $entityObj->id;
$subscribe->interval = $interval;
return $subscribe->store();
}
示例11: connect
/**
* Open an IMAP stream to a mailbox.
* Return true on success, return false on error.
*/
public function connect($username = '', $password = '')
{
$config = DiscussHelper::getConfig();
if (!$this->initiated) {
$this->init();
}
if (!$this->enabled || !function_exists('imap_open') || !function_exists('imap_fetchheader') || !function_exists('imap_body')) {
$this->setError('PHP IMAP not available.');
return false;
}
/*
* Connect to mailbox
*/
// if( !empty($username) && !empty($password) )
// {
echo JText::sprintf('COM_EASYDISCUSS_CONNECTING_TO', $username);
$this->stream = imap_open($this->mailbox_params, $username, $password);
// }
// else
// {
// $this->stream = imap_open( $this->mailbox_params, $this->username, $this->password );
// }
if ($this->stream === false) {
$this->setError(imap_errors());
return false;
}
return true;
}
示例12: delete
public function delete($id)
{
$ajax = new Disjax();
$user = JFactory::getUser();
// @rule: Do not allow empty id or guests to delete files.
if (empty($id) || empty($user->id)) {
return false;
}
$attachment = DiscussHelper::getTable('Attachments');
$attachment->load($id);
// Ensure that only post owner or admin can delete it.
if (!$attachment->deleteable()) {
return false;
}
// Ensure that only post owner or admin can delete it.
if (!$attachment->delete()) {
return false;
}
$theme = new DiscussThemes();
$content = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETED_SUCCESSFULLY');
$options = new stdClass();
$options->content = $content;
$options->title = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETE_CONFIRMATION_TITLE');
$buttons = array();
$button = new stdClass();
$button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
$button->action = 'disjax.closedlg();';
$buttons[] = $button;
$options->buttons = $buttons;
$ajax->script('EasyDiscuss.$("#attachment-' . $attachment->id . '" ).trigger("itemRemoved").remove();');
$ajax->dialog($options);
$ajax->send();
}
示例13: get
public function get($key, $default = null)
{
if (DiscussHelper::getJoomlaVersion() >= '3.0') {
return $this->config->get($key, $default);
}
return $this->config->getValue($key, $default);
}
示例14: exists
/**
* Test if a specific rule / command already exists on the system.
*
* @access public
* @param string $command The command name to test for.
* @return boolean True if exists, false otherwise.
**/
public function exists($command)
{
$db = DiscussHelper::getDBO();
$query = 'SELECT COUNT(1) FROM ' . $db->nameQuote($this->_tbl) . ' ' . 'WHERE ' . $db->nameQuote('command') . '=' . $db->Quote($command);
$db->setQuery($query);
return $db->loadResult() > 0;
}
示例15: getButtonHTML
public static function getButtonHTML($row, $position = 'vertical')
{
$config = DiscussHelper::getConfig();
if (!$config->get('integration_digg')) {
return '';
}
$dataURL = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row->id, false, true);
$dataURL = urlencode($dataURL);
$html = '';
if ($position == 'horizontal') {
$class = 'DiggCompact';
} else {
$class = 'DiggMedium';
}
$html = '<script type="text/javascript">(function() {
var s = document.createElement(\'SCRIPT\'), s1 = document.getElementsByTagName(\'SCRIPT\')[0];
s.type = \'text/javascript\';
s.async = true;
s.src = \'http://widgets.digg.com/buttons.js\';
s1.parentNode.insertBefore(s, s1);
})();
</script>
<!-- Wide Button -->
<div class="social-button digg-share"><a class="DiggThisButton ' . $class . '" href="https://digg.com/submit?url=' . $dataURL . '&title=' . $row->title . '"></a></div>';
return $html;
}