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
109 changes: 103 additions & 6 deletions modules/mod_finder/mod_finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Finder\Administrator\Helper\LanguageHelper;
use Joomla\Component\Finder\Site\Helper\RouteHelper;
use Joomla\Module\Finder\Site\Helper\FinderHelper;
// TS change - start
// use Joomla\Component\Videos\Site\Helper\Videos;
use Joomla\Module\Finder\Site\Module\FinderModule;
// TS change - end

$cparams = ComponentHelper::getParams('com_finder');

Expand All @@ -36,11 +39,11 @@
// Get the route.
$route = RouteHelper::getSearchRoute($params->get('searchfilter', null));

if ($params->get('set_itemid')) {
$uri = Uri::getInstance($route);
$uri->setVar('Itemid', $params->get('set_itemid'));
$route = $uri->toString(array('path', 'query'));
// TS change - start
if ((int) $params->get('set_itemid') > 0) {
$route = 'index.php?Itemid=' . $params->get('set_itemid');
}
// TS change - end

// Load component language file.
LanguageHelper::loadComponentLanguage();
Expand All @@ -51,4 +54,98 @@
// Get Smart Search query object.
$query = FinderHelper::getQuery($params);

require ModuleHelper::getLayoutPath('mod_finder', $params->get('layout', 'default'));
// TS change - start
// $videos = VideosFrontendHelper::getModel('Frontend');
// $subjects = $videos->getSubjects();
// $levels = $videos->getLevels();
// $types = $videos->getTypes();

// To remove - start
$subjects = [
(object) [
'id' => '1',
'subject_title' => 'Matematyka',
'state' => '1',
'ordering' => '1',
],
(object) [
'id' => '2',
'subject_title' => 'Fizyka',
'state' => '1',
'ordering' => '2',
],
(object) [
'id' => '3',
'subject_title' => 'Chemia',
'state' => '1',
'ordering' => '3',
],
(object) [
'id' => '4',
'subject_title' => 'Biologia',
'state' => '1',
'ordering' => '4',
],
];

$levels = [
(object) [
'id' => '2',
'level_title' => 'Szkoła Podstawowa IV-VI',
'state' => '1',
'ordering' => '2',
],
(object) [
'id' => '5',
'level_title' => 'Szkoła Podstawowa VII-VIII',
'state' => '1',
'ordering' => '5',
],
(object) [
'id' => '6',
'level_title' => 'Szkoła Ponadpodstawowa',
'state' => '1',
'ordering' => '6',
],
];

$types = [
(object) [
'id' => '1',
'type_title' => 'Film',
'state' => '1',
],
(object) [
'id' => '2',
'type_title' => 'Playlista',
'state' => '1',
],
(object) [
'id' => '3',
'type_title' => 'Zadanie',
'state' => '1',
],
(object) [
'id' => '4',
'type_title' => 'Riddle',
'state' => '1',
],
];
// To remove - end

$data = [
'route' => $route,
'query' => $query,
'search' => htmlspecialchars(JFactory::getApplication()->input->get('q', '', 'string')),
'subjects' => $subjects,
'levels' => $levels,
'types' => $types,
];

$modInstance = new FinderModule($params, $module);
$modInstance->setData($data);

$layout = '@module/mod_finder/' . explode(':', $params->get('layout', 'default'))[1] . '/' . explode(':', $params->get('layout', 'default'))[1] . '.html.twig';

echo $modInstance->render($layout);
// TS change - end
59 changes: 59 additions & 0 deletions modules/mod_finder/src/Module/FinderModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* @version 3.0.0
* @package Joomla.Site
* @subpackage mod_finder
*
* @copyright Copyright (C) Katalyst Education 2015. Wszystkie prawa zastrzeżone.
* @license GNU General Public License v2 lub późniejsza; zobacz LICENSE.txt
* @author Tomasz Stach <tomasz.stach@katalysteducation.org> - http://katalysteducation.org
*/

namespace Joomla\Module\Finder\Site\Module;

defined('_JEXEC') || die;

\JLoader::import('twig.library');

use Phproberto\Joomla\Twig\Module\BaseTwigModule;

/**
* Finder module.
*
* @since 3.0.0
*/
class FinderModule extends BaseTwigModule
{
/**
* Module created by module
*
* @var string
*/
protected $data;

/**
* Method to set data from module.
*
* @param array $data
*/
public function setData(array $data): void
{
$this->data = $data;
}

/**
* Load layout data.
*
* @return array
*/
protected function loadLayoutData(): array
{
return [
'cssClass' => $this->getCssClass(),
'cssId' => $this->getCssId(),
'moduleInstance' => $this,
'params' => $this->getParams(),
'data' => $this->data,
];
}
}
37 changes: 37 additions & 0 deletions modules/mod_finder/tmpl/default.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h3>moduleInstance</h3>
<pre>{{ dump(moduleInstance) }}</pre>

<h3>params</h3>
<pre>{{ dump(params) }}</pre>

<h3>route</h3>
<pre>{{ dump(data.route) }}</pre>

<h3>query</h3>
<pre>{{ dump(data.query) }}</pre>

<h3>search</h3>
<pre>{{ dump(data.search) }}</pre>

<h3>subjects</h3>
<pre>{{ dump(data.subjects) }}</pre>

<h3>levels</h3>
<pre>{{ dump(data.levels) }}</pre>

<h3>types</h3>
<pre>{{ dump(data.types) }}</pre>

<!-- SEARCHBOX -->
<section data-ee="SearchBox" data-mode="regular" data-click="hide()">
<a href="#" class="searchbox-button active" id="searchbox-button" data-click="open()"><i class="material-icons searchbox-button__icon">search</i></a>
<div class="searchbox" id="SearchBox" action="{{ jroute(data.route) }}">
<div class="searchbox__box">
<div class="searchbox__box__input">
<input id="SearchInput" type="text" name="search" value="{{ data.search }}" placeholder="Wpisz tytuł wideo, kod podstawy lub szukaną frazę...">
<a href="#" class="searchbox__box__input__close" data-click="close()"><i class="material-icons searchbox__box__input__close__icon">close</i></a>
</div>
</div>
</div>
</section>
<!-- ./SEARCHBOX -->
56 changes: 56 additions & 0 deletions modules/mod_finder/tmpl/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## Info

**Module:** mod_finder

**Template:** default

**Description:** This is the view which we use to display a searchbox.

## Data

### {{ data.route }}

This is a url for the form action.

### {{ data.query }}

This is a query object.

### {{ data.search }}

This is a searched phrase.

### {{ data.subjects }}

This is a list of available subjects.

### {{ data.levels }}

This is a list of available levels.

### {{ data.types }}

This is a list of available types.

### {{ class_sfx }}

CSS class suffix.

**Tips:**

- old version of searchbox:
```
<!-- SEARCHBOX -->
<section data-ee="SearchBox" data-mode="regular" data-click="hide()">
<a href="#" class="searchbox-button active" id="searchbox-button" data-click="open()"><i class="material-icons searchbox-button__icon">search</i></a>
<div class="searchbox" id="SearchBox" action="{{ jroute(data.route) }}">
<div class="searchbox__box">
<div class="searchbox__box__input">
<input id="SearchInput" type="text" name="search" value="{{ data.search }}" placeholder="Wpisz tytuł wideo, kod podstawy lub szukaną frazę...">
<a href="#" class="searchbox__box__input__close" data-click="close()"><i class="material-icons searchbox__box__input__close__icon">close</i></a>
</div>
</div>
</div>
</section>
<!-- ./SEARCHBOX -->
```
74 changes: 1 addition & 73 deletions modules/mod_finder/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -1,73 +1 @@
<?php

/**
* @package Joomla.Site
* @subpackage mod_finder
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\Module\Finder\Site\Helper\FinderHelper;

// Load the smart search component language file.
$lang = $app->getLanguage();
$lang->load('com_finder', JPATH_SITE);

$input = '<input type="text" name="q" id="mod-finder-searchword' . $module->id . '" class="js-finder-search-query form-control" value="' . htmlspecialchars($app->input->get('q', '', 'string'), ENT_COMPAT, 'UTF-8') . '"'
. ' placeholder="' . Text::_('MOD_FINDER_SEARCH_VALUE') . '">';

$showLabel = $params->get('show_label', 1);
$labelClass = (!$showLabel ? 'visually-hidden ' : '') . 'finder';
$label = '<label for="mod-finder-searchword' . $module->id . '" class="' . $labelClass . '">' . $params->get('alt_label', Text::_('JSEARCH_FILTER_SUBMIT')) . '</label>';

$output = '';

if ($params->get('show_button', 0)) {
$output .= $label;
$output .= '<div class="mod-finder__search input-group">';
$output .= $input;
$output .= '<button class="btn btn-primary" type="submit"><span class="icon-search icon-white" aria-hidden="true"></span> ' . Text::_('JSEARCH_FILTER_SUBMIT') . '</button>';
$output .= '</div>';
} else {
$output .= $label;
$output .= $input;
}

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

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $app->getDocument()->getWebAssetManager();
$wa->getRegistry()->addExtensionRegistryFile('com_finder');

/*
* This segment of code sets up the autocompleter.
*/
if ($params->get('show_autosuggest', 1)) {
$wa->usePreset('awesomplete');
$app->getDocument()->addScriptOptions('finder-search', array('url' => Route::_('index.php?option=com_finder&task=suggestions.suggest&format=json&tmpl=component', false)));
}

$wa->useScript('com_finder.finder');

?>

<form class="mod-finder js-finder-searchform form-search" action="<?php echo Route::_($route); ?>" method="get" role="search">
<?php echo $output; ?>

<?php $show_advanced = $params->get('show_advanced', 0); ?>
<?php if ($show_advanced == 2) : ?>
<br>
<a href="<?php echo Route::_($route); ?>" class="mod-finder__advanced-link"><?php echo Text::_('COM_FINDER_ADVANCED_SEARCH'); ?></a>
<?php elseif ($show_advanced == 1) : ?>
<div class="mod-finder__advanced js-finder-advanced">
<?php echo HTMLHelper::_('filter.select', $query, $params); ?>
</div>
<?php endif; ?>
<?php echo FinderHelper::getGetFields($route, (int) $params->get('set_itemid', 0)); ?>
</form>
<?php defined('_JEXEC') or die; ?>
Loading