This commit is contained in:
2024-12-31 11:07:09 +01:00
parent df7915205d
commit e089172b15
1916 changed files with 165422 additions and 271 deletions

View File

@ -0,0 +1,86 @@
<?php
/**
* @package Advanced Custom Fields
* @version 2.8.8 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
if (!$articles = $field->value)
{
return;
}
$routerHelper = defined('nrJ4') ? 'Joomla\Component\Content\Site\Helper\RouteHelper' : 'ContentHelperRoute';
// Get the layout
$layout = $fieldParams->get('layout', 'media/plg_fields_acfarticles/img/alist.svg');
$layout = str_replace(['media/plg_fields_acfarticles/img/', '.svg'], '', $layout);
$layout = ltrim($layout, 'a');
$customLayout = $fieldParams->get('custom_layout', '');
if ($layout === 'custom' && !$customLayout)
{
return;
}
$id = 'acf_articles_' . $item->id . '_' . $field->id;
// Set the wrapper classes
$classes = [];
$classes[] = $id;
$classes[] = 'layout-' . $layout;
if (in_array($layout, ['stylea', 'styleb']))
{
$classes[] = 'layout-grid';
}
// Set columns and gap
if (in_array($layout, ['stylea', 'styleb']))
{
// Get columns and gap
$columns = $fieldParams->get('devices_columns.columns', []);
$gap = $fieldParams->get('devices_gap.gap', []);
Factory::getDocument()->addStyleDeclaration('
.acfarticles-field-wrapper.' . $id . ' {
--columns: ' . $columns['desktop'] . ';
--gap: ' . $gap['desktop'] . 'px;
}
@media only screen and (max-width: 991px) {
.acfarticles-field-wrapper.' . $id . ' {
--columns: ' . $columns['tablet'] . ';
--gap: ' . $gap['tablet'] . 'px;
}
}
@media only screen and (max-width: 575px) {
.acfarticles-field-wrapper.' . $id . ' {
--columns: ' . $columns['mobile'] . ';
--gap: ' . $gap['mobile'] . 'px;
}
}
');
}
$html = '<div class="acfarticles-field-wrapper ' . implode(' ', $classes) . '">';
$path = __DIR__ . '/layouts/' . $layout . '.php';
if (file_exists($path))
{
require $path;
}
$html .= '</div>';
echo $html;

View File

@ -0,0 +1,39 @@
<?php
/**
* @package Advanced Custom Fields
* @version 2.8.8 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
$customLayout = HTMLHelper::_('content.prepare', $customLayout);
$st = new \NRFramework\SmartTags();
// Add total articles
$st->add(['total' => count($articles)], 'acf.articles.');
// Set the pattern
$pattern = '/\{(acf\.)?article\.([^}]+)\}/';
foreach ($articles as $index => $article)
{
// Add article index
$st->add(['index' => $index + 1], 'acf.articles.');
// Set the replacement
$replacement = '{article.$2 --id=' . $article['id'] . ' --prepareCustomFields=false}';
// Get updated layout
$tmpCustomLayout = preg_replace($pattern, $replacement, $customLayout);
$html .= $st->replace($tmpCustomLayout);
}

View File

@ -0,0 +1,24 @@
<?php
/**
* @package Advanced Custom Fields
* @version 2.8.8 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Router\Route;
$html .= '<ul>';
foreach ($articles as $article)
{
$html .= '<li><a href="' . Route::_($routerHelper::getArticleRoute($article['id'], $article['catid'], $article['language'])) . '">' . $article['title'] . '</a></li>';
}
$html .= '</ul>';

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Advanced Custom Fields
* @version 2.8.8 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper;
if (defined('nrJ4'))
{
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerAndUseStyle('acf_articles_style', 'plg_fields_acfarticles/style.css');
}
else
{
HTMLHelper::stylesheet('plg_fields_acfarticles/style.css', ['relative' => true, 'version' => 'auto']);
}
foreach ($articles as $article)
{
$image = '';
if (isset($article['images']) && $image = json_decode($article['images']))
{
$image = $image->image_intro ?: $image->image_fulltext;
}
$html .= '<div class="acfarticle-item">';
if ($image)
{
$html .= '<img src="' . $image . '" class="acfarticle-item--image" alt="' . $article['title'] . '" loading="lazy" />';
}
$html .= '<a href="' . Route::_($routerHelper::getArticleRoute($article['id'], $article['catid'], $article['language'])) . '" class="acfarticle-item--content--title">' . $article['title'] . '</a>';
$html .= '</div>';
}

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Advanced Custom Fields
* @version 2.8.8 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper;
if (defined('nrJ4'))
{
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerAndUseStyle('acf_articles_style', 'plg_fields_acfarticles/style.css');
}
else
{
HTMLHelper::stylesheet('plg_fields_acfarticles/style.css', ['relative' => true, 'version' => 'auto']);
}
foreach ($articles as $article)
{
$image = '';
if (isset($article['images']) && $image = json_decode($article['images']))
{
$image = $image->image_intro ?: $image->image_fulltext;
}
$html .= '<div class="acfarticle-item">';
if ($image)
{
$html .= '<img src="' . $image . '" class="acfarticle-item--image" alt="' . $article['title'] . '" loading="lazy" />';
}
$html .= '<div class="acfarticle-item--content">';
$html .= '<a href="' . Route::_($routerHelper::getArticleRoute($article['id'], $article['catid'], $article['language'])) . '" class="acfarticle-item--content--title">' . $article['title'] . '</a>';
// Get the article excerpt
if ($excerpt = substr(strip_tags($article['introtext']), 0, 200))
{
// Add the excerpt
$html .= '<div class="acfarticle-item--content--excerpt">' . $excerpt . '...</div>';
}
$html .= '</div></div>';
}