Skip to content

Commit

Permalink
Merge branch '4.0-dev' into ns-front-contact
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Jul 1, 2018
2 parents 5152e6f + 5ee7eae commit 0e75335
Show file tree
Hide file tree
Showing 39 changed files with 282 additions and 191 deletions.
15 changes: 9 additions & 6 deletions components/com_fields/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@
*/
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;

JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

$input = JFactory::getApplication()->input;
$context = JFactory::getApplication()->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD');
$input = Factory::getApplication()->input;
$context = Factory::getApplication()->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD');
$parts = FieldsHelper::extract($context);

if ($input->get('view') === 'fields' && $input->get('layout') === 'modal')
{
if (!JFactory::getUser()->authorise('core.create', $parts[0])
|| !JFactory::getUser()->authorise('core.edit', $parts[0]))
if (!Factory::getUser()->authorise('core.create', $parts[0])
|| !Factory::getUser()->authorise('core.edit', $parts[0]))
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
Factory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');

return;
}
}

$controller = JControllerLegacy::getInstance('Fields');
$controller = BaseController::getInstance('Fields');
$controller->execute($input->get('task'));
$controller->redirect();
37 changes: 21 additions & 16 deletions components/com_mailto/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\Component\Mailto\Site\Helper\MailtoHelper;
use Joomla\CMS\Mail\MailHelper;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;

/**
* Mailer Component Controller.
Expand Down Expand Up @@ -53,7 +58,7 @@ public function send()

if ($timeout == 0 || time() - $timeout < 20)
{
$this->setMessage(\JText::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');
$this->setMessage(Text::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');

return $this->mailto();
}
Expand All @@ -62,10 +67,10 @@ public function send()
$link = MailtoHelper::validateHash($this->input->get('link', '', 'post'));

// Verify that this is a local link
if (!$link || !\JUri::isInternal($link))
if (!$link || !Uri::isInternal($link))
{
// Non-local url...
$this->setMessage(\JText::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');
$this->setMessage(Text::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');

return $this->mailto();
}
Expand Down Expand Up @@ -111,22 +116,22 @@ public function send()
$email = $this->input->post->getString('mailto', '');
$sender = $this->input->post->getString('sender', '');
$from = $this->input->post->getString('from', '');
$subject_default = \JText::sprintf('COM_MAILTO_SENT_BY', $sender);
$subject_default = Text::sprintf('COM_MAILTO_SENT_BY', $sender);
$subject = $this->input->post->getString('subject', $subject_default);

// Check for a valid to address
$error = false;

if (!$email || !\JMailHelper::isEmailAddress($email))
if (!$email || !MailHelper::isEmailAddress($email))
{
$error = \JText::sprintf('COM_MAILTO_EMAIL_INVALID', $email);
$error = Text::sprintf('COM_MAILTO_EMAIL_INVALID', $email);
$this->app->enqueueMessage($error, 'warning');
}

// Check for a valid from address
if (!$from || !\JMailHelper::isEmailAddress($from))
if (!$from || !MailHelper::isEmailAddress($from))
{
$error = \JText::sprintf('COM_MAILTO_EMAIL_INVALID', $from);
$error = Text::sprintf('COM_MAILTO_EMAIL_INVALID', $from);
$this->app->enqueueMessage($error, 'warning');
}

Expand All @@ -136,22 +141,22 @@ public function send()
}

// Build the message to send
$msg = \JText::_('COM_MAILTO_EMAIL_MSG');
$msg = Text::_('COM_MAILTO_EMAIL_MSG');
$body = sprintf($msg, $SiteName, $sender, $from, $link);

// Clean the email data
$subject = \JMailHelper::cleanSubject($subject);
$body = \JMailHelper::cleanBody($body);
$subject = MailHelper::cleanSubject($subject);
$body = MailHelper::cleanBody($body);

// To send we need to use punycode.
$from = \JStringPunycode::emailToPunycode($from);
$from = \JMailHelper::cleanAddress($from);
$email = \JStringPunycode::emailToPunycode($email);
$from = PunycodeHelper::emailToPunycode($from);
$from = MailHelper::cleanAddress($from);
$email = PunycodeHelper::emailToPunycode($email);

// Send the email
if (\JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true)
if (Factory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true)
{
$this->setMessage(\JText::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');
$this->setMessage(Text::_('COM_MAILTO_EMAIL_NOT_SENT'), 'notice');

return $this->mailto();
}
Expand Down
8 changes: 5 additions & 3 deletions components/com_mailto/Helper/MailtoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;

/**
* Mailto route helper class.
*
Expand All @@ -31,7 +33,7 @@ public static function addLink($url)
$hash = sha1($url);
self::cleanHashes();

$session = \JFactory::getApplication()->getSession();
$session = Factory::getApplication()->getSession();
$mailto_links = $session->get('com_mailto.links', array());

if (!isset($mailto_links[$hash]))
Expand All @@ -58,7 +60,7 @@ public static function validateHash($hash)
$retval = false;

self::cleanHashes();
$mailto_links = \JFactory::getApplication()->getSession()->get('com_mailto.links', array());
$mailto_links = Factory::getApplication()->getSession()->get('com_mailto.links', array());

if (isset($mailto_links[$hash]))
{
Expand All @@ -85,7 +87,7 @@ public static function cleanHashes($lifetime = 1440)
if (!$cleaned)
{
$past = time() - $lifetime;
$session = \JFactory::getApplication()->getSession();
$session = Factory::getApplication()->getSession();
$mailto_links = $session->get('com_mailto.links', array());

foreach ($mailto_links as $index => $link)
Expand Down
13 changes: 8 additions & 5 deletions components/com_mailto/View/Mailto/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;

/**
* Class for Mail.
Expand Down Expand Up @@ -51,8 +54,8 @@ public function display($tpl = null)
*/
protected function getData()
{
$user = \JFactory::getUser();
$app = \JFactory::getApplication();
$user = Factory::getUser();
$app = Factory::getApplication();
$data = new \stdClass;

$input = $app->input;
Expand All @@ -61,7 +64,7 @@ protected function getData()

if ($data->link == '')
{
throw new \Exception(\JText::_('COM_MAILTO_LINK_IS_MISSING'), 400);
throw new \Exception(Text::_('COM_MAILTO_LINK_IS_MISSING'), 400);
}

// Load with previous data, if it exists
Expand All @@ -78,11 +81,11 @@ protected function getData()
else
{
$data->sender = $sender;
$data->from = \JStringPunycode::emailToPunycode($from);
$data->from = PunycodeHelper::emailToPunycode($from);
}

$data->subject = $subject;
$data->mailto = \JStringPunycode::emailToPunycode($mailto);
$data->mailto = PunycodeHelper::emailToPunycode($mailto);

return $data;
}
Expand Down
27 changes: 14 additions & 13 deletions components/com_mailto/tmpl/mailto/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;

JHtml::_('behavior.core');
JHtml::_('behavior.keepalive');
HTMLHelper::_('behavior.core');
HTMLHelper::_('behavior.keepalive');

Text::script('COM_MAILTO_EMAIL_ERR_NOINFO', true);

Expand All @@ -24,20 +25,20 @@

<div id="mailto-window" class="com-mailto p-2">
<h2>
<?php echo JText::_('COM_MAILTO_EMAIL_TO_A_FRIEND'); ?>
<?php echo Text::_('COM_MAILTO_EMAIL_TO_A_FRIEND'); ?>
</h2>
<div class="com-mailto__close mailto-close">
<a title="<?php echo JText::_('COM_MAILTO_CLOSE_WINDOW'); ?>" href="#" class="close-mailto">
<a title="<?php echo Text::_('COM_MAILTO_CLOSE_WINDOW'); ?>" href="#" class="close-mailto">
<span>
<?php echo JText::_('COM_MAILTO_CLOSE_WINDOW'); ?>
<?php echo Text::_('COM_MAILTO_CLOSE_WINDOW'); ?>
</span></a>
</div>

<form action="<?php echo JUri::base() ?>index.php" id="mailtoForm" method="post" class="com-mailto__form">
<form action="<?php echo Uri::base() ?>index.php" id="mailtoForm" method="post" class="com-mailto__form">
<div class="com-mailto__emailto control-group">
<div class="control-label">
<label for="mailto_field">
<?php echo JText::_('COM_MAILTO_EMAIL_TO'); ?>
<?php echo Text::_('COM_MAILTO_EMAIL_TO'); ?>
</label>
</div>
<div class="controls">
Expand All @@ -47,7 +48,7 @@
<div class="com-mailto__sender control-group">
<div class="control-label">
<label for="sender_field">
<?php echo JText::_('COM_MAILTO_SENDER'); ?>
<?php echo Text::_('COM_MAILTO_SENDER'); ?>
</label>
</div>
<div class="controls">
Expand All @@ -57,7 +58,7 @@
<div class="com-mailto__your-email control-group">
<div class="control-label">
<label for="from_field">
<?php echo JText::_('COM_MAILTO_YOUR_EMAIL'); ?>
<?php echo Text::_('COM_MAILTO_YOUR_EMAIL'); ?>
</label>
</div>
<div class="controls">
Expand All @@ -67,7 +68,7 @@
<div class="com-mailto__subject control-group">
<div class="control-label">
<label for="subject_field">
<?php echo JText::_('COM_MAILTO_SUBJECT'); ?>
<?php echo Text::_('COM_MAILTO_SUBJECT'); ?>
</label>
</div>
<div class="controls">
Expand All @@ -76,10 +77,10 @@
</div>
<div class="com-mailto__submit control-group">
<button type="button" class="com-mailto__cancel btn btn-danger close-mailto">
<?php echo JText::_('COM_MAILTO_CANCEL'); ?>
<?php echo Text::_('COM_MAILTO_CANCEL'); ?>
</button>
<button type="submit" class="com-mailto__send btn btn-success">
<?php echo JText::_('COM_MAILTO_SEND'); ?>
<?php echo Text::_('COM_MAILTO_SEND'); ?>
</button>
</div>

Expand All @@ -88,6 +89,6 @@
<input type="hidden" name="task" value="send">
<input type="hidden" name="tmpl" value="component">
<input type="hidden" name="link" value="<?php echo $data->link; ?>">
<?php echo JHtml::_('form.token'); ?>
<?php echo HTMLHelper::_('form.token'); ?>
</form>
</div>
7 changes: 5 additions & 2 deletions components/com_mailto/tmpl/sent/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

?>
<div class="com-mailto-send p-2">
<div class="com-mailto-send__close text-right">
<a href="javascript: void window.close()">
<?php echo JText::_('COM_MAILTO_CLOSE_WINDOW'); ?> <?php echo JHtml::_('image', 'mailto/close-x.png', null, null, true); ?>
<?php echo Text::_('COM_MAILTO_CLOSE_WINDOW'); ?> <?php echo HTMLHelper::_('image', 'mailto/close-x.png', null, null, true); ?>
</a>
</div>
<h2 class="com-mailto-send__message">
<?php echo JText::_('COM_MAILTO_EMAIL_SENT'); ?>
<?php echo Text::_('COM_MAILTO_EMAIL_SENT'); ?>
</h2>
</div>
3 changes: 2 additions & 1 deletion components/com_newsfeeds/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;

/**
* Newsfeeds Component Controller
Expand All @@ -37,7 +38,7 @@ public function display($cachable = false, $urlparams = false)
$vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName);

if (\JFactory::getUser()->get('id') || ($this->input->getMethod() === 'POST' && $vName === 'category' ))
if (Factory::getUser()->get('id') || ($this->input->getMethod() === 'POST' && $vName === 'category' ))
{
$cachable = false;
}
Expand Down
7 changes: 4 additions & 3 deletions components/com_newsfeeds/Helper/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
*/
namespace Joomla\Component\Newsfeeds\Site\Helper;

use Joomla\CMS\Language\Multilanguage;

defined('_JEXEC') or die;

use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Categories\CategoryNode;

/**
* Newsfeeds Component Route Helper
*
Expand Down Expand Up @@ -56,7 +57,7 @@ public static function getNewsfeedRoute($id, $catid, $language = 0)
*/
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof \JCategoryNode)
if ($catid instanceof CategoryNode)
{
$id = $catid->id;
}
Expand Down
8 changes: 5 additions & 3 deletions components/com_newsfeeds/Model/CategoriesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Registry\Registry;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Factory;

/**
* This models supports retrieving lists of newsfeed categories.
Expand Down Expand Up @@ -54,7 +56,7 @@ class CategoriesModel extends ListModel
*/
protected function populateState($ordering = null, $direction = null)
{
$app = \JFactory::getApplication();
$app = Factory::getApplication();
$this->setState('filter.extension', $this->_extension);

// Get the parent id if defined.
Expand Down Expand Up @@ -99,7 +101,7 @@ public function getItems()
{
if ($this->_items === null)
{
$app = \JFactory::getApplication();
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new Registry;
Expand All @@ -111,7 +113,7 @@ public function getItems()

$options = array();
$options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = \JCategories::getInstance('Newsfeeds', $options);
$categories = Categories::getInstance('Newsfeeds', $options);
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));

if (is_object($this->_parent))
Expand Down

0 comments on commit 0e75335

Please sign in to comment.