Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions fields/Layouts/Helper/LayoutPathsHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php namespace JPATHRU\Libraries\Fields\Layouts\Helper;
<?php

defined('JPATH_PLATFORM') or die;
namespace JPATHRU\Libraries\Fields\Layouts\Helper;

defined('_JEXEC') or die;

use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
Expand All @@ -10,10 +12,8 @@ class LayoutPathsHelper

protected $paths = [];


protected $cache_paths = [];


public function __construct($target = '', $other_paths = '', $template = '')
{

Expand Down Expand Up @@ -109,7 +109,6 @@ public function __construct($target = '', $other_paths = '', $template = '')

}


public function get($type = '')
{

Expand All @@ -128,13 +127,11 @@ public function get($type = '')
return $this->paths;
}


protected function set($paths = [])
{
$this->paths = $paths;
}


protected function add($path)
{
if (in_array($path['path'], $this->cache_paths))
Expand All @@ -149,5 +146,4 @@ protected function add($path)
return true;
}


}
8 changes: 6 additions & 2 deletions fields/Layouts/LayoutsField.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php namespace JPATHRU\Libraries\Fields\Layouts;
<?php

defined('JPATH_PLATFORM') or die;
namespace JPATHRU\Libraries\Fields\Layouts;

defined('_JEXEC') or die;

use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\HTML\HTMLHelper;
Expand All @@ -12,6 +14,8 @@
class LayoutsField extends ListField
{

public $type = 'Layouts';

public function getInput()
{
$html = [];
Expand Down
16 changes: 9 additions & 7 deletions fields/Layouts/LayoutsmoduleField.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php namespace JPATHRU\Libraries\Fields\Layouts;
<?php

defined('JPATH_PLATFORM') or die;
namespace JPATHRU\Libraries\Fields\Layouts;

defined('_JEXEC') or die;

/**
* @package Joomla.Legacy
Expand All @@ -11,16 +13,17 @@

use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Path;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseDriver;
use Joomla\Filesystem\Folder;

class LayoutsmoduleField extends FormField
{
protected $type = 'layoutsmodule';
protected $type = 'Layoutsmodule';

protected function getInput()
{
Expand All @@ -46,7 +49,6 @@ protected function getInput()

if ($module && $client)
{

$template = (string) $this->element['template'];
$template = preg_replace('#\W#', '', $template);

Expand All @@ -57,11 +59,11 @@ protected function getInput()
$template_style_id = preg_replace('#\W#', '', $template_style_id);
}

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($module . '.sys', $client->path, null, false, true)
|| $lang->load($module . '.sys', $client->path . '/modules/' . $module, null, false, true);

$db = Factory::getDbo();
$db = Factory::getContainer()->get(DatabaseDriver::class);
$query = $db->getQuery(true);

$query
Expand Down
19 changes: 10 additions & 9 deletions fields/Layouts/LayoutspluginField.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php namespace JPATHRU\Libraries\Fields\Layouts;
<?php

defined('JPATH_PLATFORM') or die;
namespace JPATHRU\Libraries\Fields\Layouts;

defined('_JEXEC') or die;

/**
* @package Joomla.Legacy
Expand All @@ -11,16 +13,17 @@

use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\Filesystem\Path;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseDriver;
use Joomla\Filesystem\Folder;

class LayoutspluginField extends FormField
{
protected $type = 'layoutsplugin';
protected $type = 'Layoutsplugin';

protected function getInput()
{
Expand Down Expand Up @@ -53,9 +56,6 @@ protected function getInput()

if ($plugin && $client)
{

$pluginFullName = 'plg_' . $folder . '_' . $plugin;

$template = (string) $this->element['template'];
$template = preg_replace('#\W#', '', $template);

Expand All @@ -66,11 +66,12 @@ protected function getInput()
$template_style_id = preg_replace('#\W#', '', $template_style_id);
}

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($plugin . '.sys', $client->path, null, false, true)
|| $lang->load($plugin . '.sys', $client->path . '/plugins/' . $folder . '/' . $plugin, null, false, true);

$db = Factory::getDbo();
/** @var DatabaseDriver $db */
$db = Factory::getContainer()->get(DatabaseDriver::class);
$query = $db->getQuery(true);

$query
Expand Down
2 changes: 1 addition & 1 deletion fields/ListArticles/ListarticlesField.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ListarticlesField extends ListField
* @var string
* @since 1.6
*/
public $type = 'ListArticles';
public $type = 'Listarticles';

/**
*
Expand Down
17 changes: 10 additions & 7 deletions fields/ListArticles/helpers/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Database\DatabaseDriver;
use Joomla\Utilities\ArrayHelper;

/**
Expand Down Expand Up @@ -35,20 +36,22 @@ public static function options($config = [])
$config = array_merge($config, [
'filter.published' => [0, 1]
]);
$hash = md5('lib_fields' . '.' . serialize($config));
$hash = md5('lib_fields' . '.' . serialize($config));

if (!isset(static::$items[$hash]))
{
$config = (array) $config;
$db = Factory::getDbo();
$user = Factory::getUser();
/** @var DatabaseDriver $db */
$db = Factory::getContainer()->get(DatabaseDriver::class);
$user = Factory::getApplication()->getIdentity();
$groups = implode(',', $user->getAuthorisedViewLevels());

$query = $db->getQuery(true)
->select("con.id, REPLACE(con.title, '\"', '') as title, con.language")
->from('#__content AS con');

if(isset($config['filter.category'])) {
if (isset($config['filter.category']))
{
$category = (int) $config['filter.category'];
$query->innerJoin("(SELECT node.id FROM #__categories AS node, #__categories AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND (parent.parent_id = " . $category . " OR parent.id = " . $category . ") ORDER BY node.lft) AS cat ON (con.catid = cat.id)");
}
Expand Down Expand Up @@ -88,21 +91,21 @@ public static function options($config = [])
// Filter on the language
if (isset($config['filter.q']))
{
$search = $db->Quote( '%' . $db->escape( $config['filter.q'], true ) . '%' );
$search = $db->Quote('%' . $db->escape($config['filter.q'], true) . '%');

$query->where("title LIKE " . $search);
}

// Filter on the language
if (isset($config['filter.limit']))
{
$query->setLimit((int)$config['filter.limit']);
$query->setLimit((int) $config['filter.limit']);
}

// Filter on the language
if (isset($config['filter.ids']))
{
$ids = $db->escape( implode(',', $config['filter.ids']), true );
$ids = $db->escape(implode(',', $config['filter.ids']), true);
$query->where("con.id in (" . $ids . ')');
}

Expand Down
68 changes: 13 additions & 55 deletions fields/ListComponents/ListcomponentsField.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace JPATHRU\Libraries\Fields\ListComponents;
<?php

namespace JPATHRU\Libraries\Fields\ListComponents;

/**
* @package Joomla! fields library
Expand All @@ -17,54 +19,30 @@

defined('_JEXEC') or die;

use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\Filesystem\File;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Version;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseDriver;
use stdClass;

class ListcomponentsField extends ListField
{
/**
* The form field type.
*
* @var string
*
* @since 1.1.0
*/
protected $type = 'listcomponents';


/**
* Field options array.
*
* @var array
*
* @since 1.1.0
*/
protected $_options = null;

protected $type = 'Listcomponents';

protected $_options = null;

/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @throws Exception
*
* @since 1.1.0
*/
protected function getOptions()
{

if ($this->_options === null)
{
// Get components
$db = Factory::getDbo();
/** @var DatabaseDriver $db */
$db = Factory::getContainer()->get(DatabaseDriver::class);
$query = $db->getQuery(true)
->select(['e.element'])
->from($db->quoteName('#__extensions', 'e'))
Expand Down Expand Up @@ -98,7 +76,6 @@ protected function getOptions()
}
}

// Convert options
$options = parent::getOptions();

foreach ($options as $key => $option)
Expand Down Expand Up @@ -133,9 +110,8 @@ protected function getOptions()

}

// Prepare options
$pluginConstant = 'LIB_FIELDS_FIELD_LIST_COMPONENTS';
$language = Factory::getLanguage();
$language = Factory::getApplication()->getLanguage();
$language_tag = $language->getTag();
$language->load('lib_fields', JPATH_SITE, $language_tag, true);
foreach ($components as $component => $views)
Expand All @@ -145,7 +121,6 @@ protected function getOptions()
$componentText = ($language->hasKey($componentConstant)) ? Text::_($componentConstant) :
ucfirst(str_replace('com_', '', $component));

// Add views
foreach ($views as $view => $layouts)
{
$viewValue = $componentValue . '.' . $view;
Expand All @@ -158,7 +133,6 @@ protected function getOptions()
$option->text = $viewText;
$options[] = $option;

// Add layouts
foreach ($layouts as $layout)
{
$layoutValue = $viewValue . ':' . $layout;
Expand All @@ -181,14 +155,6 @@ protected function getOptions()
return $this->_options;
}

/**
* Check if relevant folder exists with different paths for J3 and J4
*
* @param string $component
* @param string $rootComponents
*
* @return string|bool
*/
private static function checkFolder(string $component, string $rootComponents = JPATH_ROOT)
{
$jversion = new Version();
Expand All @@ -209,14 +175,6 @@ private static function checkFolder(string $component, string $rootComponents =
return false;
}

/**
* Check if there is an edit option in views for J4
*
* @param string $folder
* @param string $view
*
* @return bool
*/
private static function checkEditOption(string $folder, string $view)
{
$editFile = $folder . DIRECTORY_SEPARATOR . $view . DIRECTORY_SEPARATOR . 'edit.php';
Expand Down
Loading