first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
/* ==== GRID SYSTEM ==== */
.container {
width: 90%;
margin-left: auto;
margin-right: auto;
}
.row {
position: relative;
width: 100%;
}
.row [class^="col"] {
float: left;
margin: 0.5rem 2%;
min-height: 0.125rem;
}
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12 {
width: 96%;
}
.col-1-sm {
width: 4.33%;
}
.col-2-sm {
width: 12.66%;
}
.col-3-sm {
width: 21%;
}
.col-4-sm {
width: 29.33%;
}
.col-5-sm {
width: 37.66%;
}
.col-6-sm {
width: 46%;
}
.col-7-sm {
width: 54.33%;
}
.col-8-sm {
width: 62.66%;
}
.col-9-sm {
width: 71%;
}
.col-10-sm {
width: 79.33%;
}
.col-11-sm {
width: 87.66%;
}
.col-12-sm {
width: 96%;
}
.row::after {
content: "";
display: table;
clear: both;
}
.hidden-sm {
display: none;
}
@media only screen and (min-width: 33.75em) { /* 540px */
.container {
width: 80%;
}
}
@media only screen and (min-width: 45em) { /* 720px */
.col-1 {
width: 4.33%;
}
.col-2 {
width: 12.66%;
}
.col-3 {
width: 21%;
}
.col-4 {
width: 29.33%;
}
.col-5 {
width: 37.66%;
}
.col-6 {
width: 46%;
}
.col-7 {
width: 54.33%;
}
.col-8 {
width: 62.66%;
}
.col-9 {
width: 71%;
}
.col-10 {
width: 79.33%;
}
.col-11 {
width: 87.66%;
}
.col-12 {
width: 96%;
}
.hidden-sm {
display: block;
}
}
@media only screen and (min-width: 60em) { /* 960px */
.container {
width: 75%;
max-width: 60rem;
}
}

View File

@@ -0,0 +1,61 @@
.com_dvtr_employees .social-media img
{
width: 30px;
height: 30px;
}
.com_dvtr_employees .social-media
{
text-align: center;
}
.com_dvtr_employees .social-media a
{
color: inherit !important;
text-decoration: none !important;
}
.com_dvtr_employees .employee-avatar
{
text-align: center;
}
.com_dvtr_employees .employee-name
{
text-align: center;
font-size: 24px;
margin-bottom: 10px;
}
/* widok pracownika */
.com_dvtr_employees.view-employee .name
{
text-align: center;
}
.com_dvtr_employees.view-employee .desc
{
margin-bottom: 30px;
}
.com_dvtr_employees.view-employee .publications
{
margin-bottom: 30px;
}
.com_dvtr_employees.view-employee .name h1
{
text-transform: none;
margin-bottom: 30px;
}
.com_dvtr_employees.view-employee .avatar
{
text-align: center;
}
.com_dvtr_employees.view-employee .contact_data
{
text-align: center;
}
.com_dvtr_employees.view-employee .achievements
{
text-align: center;
}
.com_dvtr_employees .okruszki li
{
display: block !important;
}

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field name="search" type="text" hint="COM_DVTR_EMPLOYEES_SEARCH_FILTER_SUBMIT"
label="COM_USERS_FILTER_SEARCH_DESC"
class="js-stools-search-string" />
<field name="language" label="COM_DVTR_EMPLOYEES_FORM_LBL_EMPLOYEE_LANGUAGE" type="contentlanguage" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
</fields>
<fields name="list">
<field name="fullordering"
type="list"
label="COM_DVTR_EMPLOYEES_LIST_FULL_ORDERING"
description="COM_DVTR_EMPLOYEES_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.id ASC">COM_DVTR_EMPLOYEES_ID_ASC</option><option value="a.id DESC">COM_DVTR_EMPLOYEES_ID_DESC</option><option value="a.name ASC">COM_DVTR_EMPLOYEES_NAME_ASC</option><option value="a.name DESC">COM_DVTR_EMPLOYEES_NAME_DESC</option><option value="a.position ASC">COM_DVTR_EMPLOYEES_POSITION_ASC</option><option value="a.position DESC">COM_DVTR_EMPLOYEES_POSITION_DESC</option><option value="a.language ASC">COM_DVTR_EMPLOYEES_LANGUAGE_ASC</option><option value="a.language DESC">COM_DVTR_EMPLOYEES_LANGUAGE_DESC</option>
</field>
<field name="limit"
type="limitbox"
label="COM_DVTR_EMPLOYEES_LIST_LIMIT"
description="COM_DVTR_EMPLOYEES_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>

View File

@@ -0,0 +1 @@
<html><body></body></html>

View File

@@ -0,0 +1,64 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
/**
* Display Component Controller
*
* @since 1.0.0
*/
class DisplayController extends \Joomla\CMS\MVC\Controller\BaseController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param Input $input Input
*
* @since 1.0.0
*/
public function __construct($config = array(), ?MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);
}
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached.
* @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link InputFilter::clean()}.
*
* @return \Joomla\CMS\MVC\Controller\BaseController This object to support chaining.
*
* @since 1.0.0
*/
public function display($cachable = false, $urlparams = false)
{
$view = $this->input->getCmd('view', 'employees');
$view = $view == "featured" ? 'employees' : $view;
$this->input->set('view', $view);
parent::display($cachable, $urlparams);
return $this;
}
}

View File

@@ -0,0 +1,176 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Controller;
\defined('_JEXEC') or die;
use \Joomla\CMS\Application\SiteApplication;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Multilanguage;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\MVC\Controller\BaseController;
use \Joomla\CMS\Router\Route;
use \Joomla\CMS\Uri\Uri;
use \Joomla\Utilities\ArrayHelper;
/**
* Employee class.
*
* @since 1.6.0
*/
class EmployeeController extends BaseController
{
/**
* Method to check out an item for editing and redirect to the edit form.
*
* @return void
*
* @since 1.0.0
*
* @throws Exception
*/
public function edit()
{
// Get the previous edit id (if any) and the current edit id.
$previousId = (int) $this->app->getUserState('com_dvtr_employees.edit.employee.id');
$editId = $this->input->getInt('id', 0);
// Set the user id for the user to edit in the session.
$this->app->setUserState('com_dvtr_employees.edit.employee.id', $editId);
// Get the model.
$model = $this->getModel('Employee', 'Site');
// Check out the item
if ($editId)
{
$model->checkout($editId);
}
// Check in the previous user.
if ($previousId && $previousId !== $editId)
{
$model->checkin($previousId);
}
// Redirect to the edit screen.
$this->setRedirect(Route::_('index.php?option=com_dvtr_employees&view=employeeform&layout=edit', false));
}
/**
* Method to save data
*
* @return void
*
* @throws Exception
* @since 1.0.0
*/
public function publish()
{
// Checking if the user can remove object
$user = $this->app->getIdentity();
if ($user->authorise('core.edit', 'com_dvtr_employees') || $user->authorise('core.edit.state', 'com_dvtr_employees'))
{
$model = $this->getModel('Employee', 'Site');
// Get the user data.
$id = $this->input->getInt('id');
$state = $this->input->getInt('state');
// Attempt to save the data.
$return = $model->publish($id, $state);
// Check for errors.
if ($return === false)
{
$this->setMessage(Text::sprintf('Save failed: %s', $model->getError()), 'warning');
}
// Clear the profile id from the session.
$this->app->setUserState('com_dvtr_employees.edit.employee.id', null);
// Flush the data from the session.
$this->app->setUserState('com_dvtr_employees.edit.employee.data', null);
// Redirect to the list screen.
$this->setMessage(Text::_('COM_DVTR_EMPLOYEES_ITEM_SAVED_SUCCESSFULLY'));
$menu = Factory::getApplication()->getMenu();
$item = $menu->getActive();
if (!$item)
{
// If there isn't any menu item active, redirect to list view
$this->setRedirect(Route::_('index.php?option=com_dvtr_employees&view=employees', false));
}
else
{
$this->setRedirect(Route::_('index.php?Itemid='. $item->id, false));
}
}
else
{
throw new \Exception(500);
}
}
/**
* Remove data
*
* @return void
*
* @throws Exception
*/
public function remove()
{
// Checking if the user can remove object
$user = $this->app->getIdentity();
if ($user->authorise('core.delete', 'com_dvtr_employees'))
{
$model = $this->getModel('Employee', 'Site');
// Get the user data.
$id = $this->input->getInt('id', 0);
// Attempt to save the data.
$return = $model->delete($id);
// Check for errors.
if ($return === false)
{
$this->setMessage(Text::sprintf('Delete failed', $model->getError()), 'warning');
}
else
{
// Check in the profile.
if ($return)
{
$model->checkin($return);
}
$this->app->setUserState('com_dvtr_employees.edit.employee.id', null);
$this->app->setUserState('com_dvtr_employees.edit.employee.data', null);
$this->app->enqueueMessage(Text::_('COM_DVTR_EMPLOYEES_ITEM_DELETED_SUCCESSFULLY'), 'success');
$this->app->redirect(Route::_('index.php?option=com_dvtr_employees&view=employees', false));
}
// Redirect to the list screen.
$menu = Factory::getApplication()->getMenu();
$item = $menu->getActive();
$this->setRedirect(Route::_($item->link, false));
}
else
{
throw new \Exception(500);
}
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Utilities\ArrayHelper;
/**
* Employees class.
*
* @since 1.0.0
*/
class EmployeesController extends FormController
{
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional
* @param array $config Configuration array for model. Optional
*
* @return object The model
*
* @since 1.0.0
*/
public function getModel($name = 'Employees', $prefix = 'Site', $config = array())
{
return parent::getModel($name, $prefix, array('ignore_request' => true));
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Form\FormField;
use \Joomla\CMS\User\UserFactoryInterface;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class CreatedbyField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'createdby';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
// Load user
$user_id = $this->value;
if ($user_id)
{
$container = \Joomla\CMS\Factory::getContainer();
$userFactory = $container->get(UserFactoryInterface::class);
$user = $userFactory->loadUserById($user_id);
}
else
{
$user = Factory::getApplication()->getIdentity();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $user->id . '" />';
}
if (!$this->hidden)
{
$html[] = "<div>" . $user->name . " (" . $user->username . ")</div>";
}
return implode($html);
}
}

View File

@@ -0,0 +1,296 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\HTML\HTMLHelper;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\Field\ListField;
/**
* Supports a value from an external table
*
* @since 1.0.0
*/
class ForeignKeyField extends ListField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'foreignkey';
protected $layout = 'joomla.form.field.list-fancy-select';
/**
* The translate.
*
* @var boolean
* @since 1.0.0
*/
protected $translate = true;
protected $header = false;
private $input_type;
private $table;
private $key_field;
private $value_field;
private $option_key_field;
private $option_value_field;
private $condition;
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function processQuery()
{
// Type of input the field shows
$this->input_type = $this->getAttribute('input_type');
// Database Table
$this->table = $this->getAttribute('table');
// The field that the field will save on the database
$this->key_field = (string) $this->getAttribute('key_field');
// The column that the field shows in the input
$this->value_field = (string) $this->getAttribute('value_field');
// The option field that the field will save on the database
$this->option_key_field = (string) $this->getAttribute('option_key_field');
// The option value that the field shows in the input
$this->option_value_field = (string) $this->getAttribute('option_value_field');
// Flag to identify if the fk_value is multiple
$this->value_multiple = (int) $this->getAttribute('value_multiple', 0);
$this->required = (string) $this->getAttribute('required', 0);
// Flag to identify if the fk_value hides the trashed items
$this->hideTrashed = (int) $this->getAttribute('hide_trashed', 0);
// Flag to identify if the fk_value hides the unpublished items
$this->hideUnpublished = (int) $this->getAttribute('hide_unpublished', 0);
// Flag to identify if the fk_value hides the published items
$this->hidePublished = (int) $this->getAttribute('hide_published', 0);
// Flag to identify if the fk_value hides the archived items
$this->hideArchived = (int) $this->getAttribute('hide_archived', 0);
// Flag to identify if the fk has default order
$this->fk_ordering = (string) $this->getAttribute('fk_ordering');
// The where SQL for foreignkey
$this->condition = (string) $this->getAttribute('condition');
// Flag for translate options
$this->translate = (bool) $this->getAttribute('translate');
// Initialize variables.
$html = '';
$fk_value = '';
// Load all the field options
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Support for multiple fields on fk_values
if ($this->value_multiple == 1)
{
// Get the fields for multiple value
$this->value_fields = (string) $this->getAttribute('value_field_multiple');
$this->value_fields = explode(',', $this->value_fields);
$this->separator = (string) $this->getAttribute('separator');
$fk_value = ' CONCAT(';
foreach ($this->value_fields as $field)
{
$fk_value .= $db->quoteName($field) . ', \'' . $this->separator . '\', ';
}
$fk_value = substr($fk_value, 0, -(strlen($this->separator) + 6));
$fk_value .= ') AS ' . $db->quoteName($this->value_field);
}
else
{
$fk_value = $db->quoteName($this->value_field);
}
$query
->select(
array(
$db->quoteName($this->key_field),
$fk_value
)
)
->from($this->table);
if ($this->hideTrashed)
{
$query->where($db->quoteName('state') . ' != -2');
}
if ($this->hideUnpublished)
{
$query->where($db->quoteName('state') . ' != 0');
}
if ($this->hidePublished)
{
$query->where($db->quoteName('state') . ' != 1');
}
if ($this->hideArchived)
{
$query->where($db->quoteName('state') . ' != 2');
}
if ($this->fk_ordering)
{
$query->order($this->fk_ordering);
}
if($this->condition)
{
$query->where($this->condition);
}
return $query;
}
/**
* Method to get the field input for a foreignkey field.
*
* @return string The field input.
*
* @since 1.0.0
*/
protected function getInput()
{
$data = $this->getLayoutData();
if (!\is_array($this->value) && !empty($this->value))
{
if (\is_object($this->value))
{
$this->value = get_object_vars($this->value);
}
// String in format 2,5,4
if (\is_string($this->value))
{
$this->value = explode(',', $this->value);
}
// Integer is given
if (\is_int($this->value))
{
$this->value = array($this->value);
}
$data['value'] = $this->value;
}
$data['options'] = $this->getOptions();
return $this->getRenderer($this->layout)->render($data);
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.0.0
*/
protected function getOptions()
{
$options = array();
$db = Factory::getContainer()->get('DatabaseDriver');
try
{
$db->setQuery($this->processQuery());
$results = $db->loadObjectList();
}
catch (ExecutionFailureException $e)
{
Factory::getApplication()->enqueueMessage(Text::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
// Add header.
if (!empty($this->header))
{
$options[] = (object) ["value" => '', "text" => Text::_($this->header)];
}
if(!empty($this->option_value_field) || !empty($this->option_key_field))
{
$options[] = (object) ["value" => $this->option_key_field, "text" => Text::_($this->option_value_field)];
}
// Build the field options.
if (!empty($results))
{
foreach ($results as $item)
{
$options[] = (object) [
"value" => $item->{$this->key_field},
"text" => $this->translate == true ? Text::_($item->{$this->value_field}) : $item->{$this->value_field}
];
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
/**
* Wrapper method for getting attributes from the form element
*
* @param string $attr_name Attribute name
* @param mixed $default Optional value to return if attribute not found
*
* @return mixed The value of the attribute if it exists, null otherwise
*/
public function getAttribute($attr_name, $default = null)
{
if (!empty($this->element[$attr_name]))
{
return $this->element[$attr_name];
}
else
{
return $default;
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Form\FormField;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class ModifiedbyField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'modifiedby';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$user = Factory::getApplication()->getIdentity();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $user->id . '" />';
if (!$this->hidden)
{
$html[] = "<div>" . $user->name . " (" . $user->username . ")</div>";
}
return implode($html);
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
defined('JPATH_BASE') or die;
use Joomla\CMS\Helper\UserGroupsHelper;
use \Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class NestedparentField extends ListField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'nestedparent';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.0.0
*/
protected function getOptions()
{
$options = array();
$table = $this->getAttribute('table');
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true)
->select('DISTINCT(a.id) AS value, a.title AS text, a.level, a.lft')
->from($table . ' AS a');
// Prevent parenting to children of this item.
if ($id = $this->form->getValue('id'))
{
$query->join('LEFT', $db->quoteName($table) . ' AS p ON p.id = ' . (int) $id)
->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (\RuntimeException $e)
{
\JError::raiseWarning(500, $e->getMessage());
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\FormField;
/**
* Class SubmitField
*
* @since 1.0.0
*/
class SubmitField extends FormField
{
protected $type = 'submit';
protected $value;
protected $for;
/**
* Get a form field markup for the input
*
* @return string
*/
public function getInput()
{
$this->value = $this->getAttribute('value');
return '<button id="' . $this->id . '"'
. ' name="submit_' . $this->for . '"'
. ' value="' . $this->value . '"'
. ' title="' . Text::_('JSEARCH_FILTER_SUBMIT') . '"'
. ' class="btn" style="margin-top: -10px;">'
. Text::_('JSEARCH_FILTER_SUBMIT')
. ' </button>';
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\FormField;
use \Joomla\CMS\Date\Date;
use Joomla\CMS\HTML\HTMLHelper;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class TimecreatedField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'timecreated';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$time_created = $this->value;
if (!strtotime($time_created))
{
$time_created = Factory::getDate()->toSql();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_created . '" />';
}
$hidden = (boolean) $this->element['hidden'];
if ($hidden == null || !$hidden)
{
$pretty_date = HTMLHelper::_('date', $time_created, Text::_('DATE_FORMAT_LC2'), true);
$html[] = "<div>" . $pretty_date . "</div>";
}
return implode($html);
}
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\FormField;
use \Joomla\CMS\Date\Date;
use Joomla\CMS\HTML\HTMLHelper;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class TimeupdatedField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'timeupdated';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$old_time_updated = $this->value;
$hidden = (boolean) $this->element['hidden'];
if ($hidden == null || !$hidden)
{
if (!strtotime($old_time_updated))
{
$html[] = '-';
}
else
{
$pretty_date = HTMLHelper::_('date', $old_time_updated, Text::_('DATE_FORMAT_LC2'), true);
$html[] = "<div>" . $pretty_date . "</div>";
}
}
$time_updated = Factory::getDate()->toSql();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_updated . '" />';
return implode($html);
}
}

View File

@@ -0,0 +1 @@
<html><body></body></html>

View File

@@ -0,0 +1,71 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Helper;
defined('_JEXEC') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\MVC\Model\BaseDatabaseModel;
/**
* Class Dvtr_employeesFrontendHelper
*
* @since 1.0.0
*/
class Dvtr_employeesHelper
{
/**
* Gets the files attached to an item
*
* @param int $pk The item's id
*
* @param string $table The table's name
*
* @param string $field The field's name
*
* @return array The files
*/
public static function getFiles($pk, $table, $field)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query
->select($field)
->from($table)
->where('id = ' . (int) $pk);
$db->setQuery($query);
return explode(',', $db->loadResult());
}
/**
* Gets the edit permission for an user
*
* @param mixed $item The item
*
* @return bool
*/
public static function canUserEdit($item)
{
$permission = false;
$user = Factory::getApplication()->getIdentity();
if ($user->authorise('core.edit', 'com_dvtr_employees') || (isset($item->created_by) && $user->authorise('core.edit.own', 'com_dvtr_employees') && $item->created_by == $user->id) || $user->authorise('core.create', 'com_dvtr_employees'))
{
$permission = true;
}
return $permission;
}
}

View File

@@ -0,0 +1 @@
<html><body></body></html>

View File

@@ -0,0 +1,326 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Model;
// No direct access.
defined('_JEXEC') or die;
use \Joomla\CMS\Factory;
use \Joomla\Utilities\ArrayHelper;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Table\Table;
use \Joomla\CMS\MVC\Model\ItemModel;
use \Joomla\CMS\Helper\TagsHelper;
use \Joomla\CMS\Object\CMSObject;
use \Joomla\CMS\User\UserFactoryInterface;
use \Dvtremployees\Component\Dvtr_employees\Site\Helper\Dvtr_employeesHelper;
/**
* Dvtr_employees model.
*
* @since 1.0.0
*/
class EmployeeModel extends ItemModel
{
public $_item;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.0.0
*
* @throws Exception
*/
protected function populateState()
{
$app = Factory::getApplication('com_dvtr_employees');
$user = $app->getIdentity();
// Check published state
if ((!$user->authorise('core.edit.state', 'com_dvtr_employees')) && (!$user->authorise('core.edit', 'com_dvtr_employees')))
{
$this->setState('filter.published', 1);
$this->setState('filter.archived', 2);
}
// Load state from the request userState on edit or from the passed variable on default
if (Factory::getApplication()->input->get('layout') == 'edit')
{
$id = Factory::getApplication()->getUserState('com_dvtr_employees.edit.employee.id');
}
else
{
$id = Factory::getApplication()->input->get('id');
Factory::getApplication()->setUserState('com_dvtr_employees.edit.employee.id', $id);
}
$this->setState('employee.id', $id);
// Load the parameters.
$params = $app->getParams();
$params_array = $params->toArray();
if (isset($params_array['item_id']))
{
$this->setState('employee.id', $params_array['item_id']);
}
$this->setState('params', $params);
}
/**
* Method to get an object.
*
* @param integer $id The id of the object to get.
*
* @return mixed Object on success, false on failure.
*
* @throws Exception
*/
public function getItem($id = null)
{
if ($this->_item === null)
{
$this->_item = false;
if (empty($id))
{
$id = $this->getState('employee.id');
}
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
if ($table && $table->load($id))
{
// Check published state.
if ($published = $this->getState('filter.published'))
{
if (isset($table->state) && $table->state != $published)
{
throw new \Exception(Text::_('COM_DVTR_EMPLOYEES_ITEM_NOT_LOADED'), 403);
}
}
// Convert the Table to a clean CMSObject.
$properties = $table->getProperties(1);
$this->_item = ArrayHelper::toObject($properties, CMSObject::class);
}
if (empty($this->_item))
{
throw new \Exception(Text::_('COM_DVTR_EMPLOYEES_ITEM_NOT_LOADED'), 404);
}
}
$container = \Joomla\CMS\Factory::getContainer();
$userFactory = $container->get(UserFactoryInterface::class);
if (isset($this->_item->created_by))
{
$user = $userFactory->loadUserById($this->_item->created_by);
$this->_item->created_by_name = $user->name;
}
$container = \Joomla\CMS\Factory::getContainer();
$userFactory = $container->get(UserFactoryInterface::class);
if (isset($this->_item->modified_by))
{
$user = $userFactory->loadUserById($this->_item->modified_by);
$this->_item->modified_by_name = $user->name;
}
return $this->_item;
}
/**
* Get an instance of Table class
*
* @param string $type Name of the Table class to get an instance of.
* @param string $prefix Prefix for the table class name. Optional.
* @param array $config Array of configuration values for the Table object. Optional.
*
* @return Table|bool Table if success, false on failure.
*/
public function getTable($type = 'Employee', $prefix = 'Administrator', $config = array())
{
return parent::getTable($type, $prefix, $config);
}
/**
* Get the id of an item by alias
* @param string $alias Item alias
*
* @return mixed
*
* @deprecated No replacement
*/
public function getItemIdByAlias($alias)
{
$table = $this->getTable();
$properties = $table->getProperties();
$result = null;
$aliasKey = null;
if (method_exists($this, 'getAliasFieldNameByView'))
{
$aliasKey = $this->getAliasFieldNameByView('employee');
}
if (key_exists('alias', $properties))
{
$table->load(array('alias' => $alias));
$result = $table->id;
}
elseif (isset($aliasKey) && key_exists($aliasKey, $properties))
{
$table->load(array($aliasKey => $alias));
$result = $table->id;
}
return $result;
}
/**
* Method to check in an item.
*
* @param integer $id The id of the row to check out.
*
* @return boolean True on success, false on failure.
*
* @since 1.0.0
*/
public function checkin($id = null)
{
// Get the id.
$id = (!empty($id)) ? $id : (int) $this->getState('employee.id');
if ($id)
{
// Initialise the table
$table = $this->getTable();
// Attempt to check the row in.
if (method_exists($table, 'checkin'))
{
if (!$table->checkin($id))
{
return false;
}
}
}
return true;
}
/**
* Method to check out an item for editing.
*
* @param integer $id The id of the row to check out.
*
* @return boolean True on success, false on failure.
*
* @since 1.0.0
*/
public function checkout($id = null)
{
// Get the user id.
$id = (!empty($id)) ? $id : (int) $this->getState('employee.id');
if ($id)
{
// Initialise the table
$table = $this->getTable();
// Get the current user object.
$user = Factory::getApplication()->getIdentity();
// Attempt to check the row out.
if (method_exists($table, 'checkout'))
{
if (!$table->checkout($user->get('id'), $id))
{
return false;
}
}
}
return true;
}
/**
* Publish the element
*
* @param int $id Item id
* @param int $state Publish state
*
* @return boolean
*/
public function publish($id, $state)
{
$table = $this->getTable();
$table->load($id);
$table->state = $state;
return $table->store();
}
/**
* Method to delete an item
*
* @param int $id Element id
*
* @return bool
*/
public function delete($id)
{
$table = $this->getTable();
return $table->delete($id);
}
public function getAliasFieldNameByView($view)
{
switch ($view)
{
case 'employee':
case 'employeeform':
return 'alias';
break;
}
}
}

View File

@@ -0,0 +1,249 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Model;
// No direct access.
defined('_JEXEC') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\MVC\Model\ListModel;
use \Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use \Joomla\CMS\Helper\TagsHelper;
use \Joomla\CMS\Layout\FileLayout;
use \Joomla\Database\ParameterType;
use \Joomla\Utilities\ArrayHelper;
use \Dvtremployees\Component\Dvtr_employees\Site\Helper\Dvtr_employeesHelper;
/**
* Methods supporting a list of Dvtr_employees records.
*
* @since 1.0.0
*/
class EmployeesModel extends ListModel
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.0.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'order', 'a.order',
'created_by', 'a.created_by',
'modified_by', 'a.modified_by',
'name', 'a.name',
'contact_data', 'a.contact_data',
'position', 'a.position',
'description', 'a.description',
'avatar', 'a.avatar',
'achievements', 'a.achievements',
'achievements_label', 'a.achievements_label',
'publications', 'a.publications',
'social_linkedin', 'a.social_linkedin',
'social_facebook', 'a.social_facebook',
'social_instagram', 'a.social_instagram',
'social_twitter', 'a.social_twitter',
'alias', 'a.alias',
'language', 'a.language',
'url', 'a.url',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering Elements order
* @param string $direction Order direction
*
* @return void
*
* @throws Exception
*
* @since 1.0.0
*/
protected function populateState($ordering = null, $direction = null)
{
// List state information.
parent::populateState('a.id', 'ASC');
$app = Factory::getApplication();
$list = $app->getUserState($this->context . '.list');
$value = $app->getUserState($this->context . '.list.limit', $app->get('list_limit', 25));
$list['limit'] = $value;
$this->setState('list.limit', $value);
$value = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $value);
$ordering = $this->getUserStateFromRequest($this->context .'.filter_order', 'filter_order', 'a.id');
$direction = strtoupper($this->getUserStateFromRequest($this->context .'.filter_order_Dir', 'filter_order_Dir', 'ASC'));
if(!empty($ordering) || !empty($direction))
{
$list['fullordering'] = $ordering . ' ' . $direction;
}
$app->setUserState($this->context . '.list', $list);
$context = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $context);
// Split context into component and optional section
if (!empty($context))
{
$parts = FieldsHelper::extract($context);
if ($parts)
{
$this->setState('filter.component', $parts[0]);
$this->setState('filter.section', $parts[1]);
}
}
}
/**
* Build an SQL query to load the list data.
*
* @return DatabaseQuery
*
* @since 1.0.0
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select', 'DISTINCT a.*'
)
);
$query->from('`#__employees_` AS a');
// Join over the created by field 'created_by'
$query->join('LEFT', '#__users AS created_by ON created_by.id = a.created_by');
// Join over the created by field 'modified_by'
$query->join('LEFT', '#__users AS modified_by ON modified_by.id = a.modified_by');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->Quote('%' . $db->escape($search, true) . '%');
}
}
// Filtering language
$app = Factory::getApplication();
$langTag = $app->getLanguage()->getTag(); // np. pl-PL
$query->where('a.language = '.$db->q($langTag).' OR language = '.$db->q('*'));
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.id');
$orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol && $orderDirn)
{
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
return $query;
}
/**
* Method to get an array of data items
*
* @return mixed An array of data on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
return $items;
}
/**
* Overrides the default function to check Date fields format, identified by
* "_dateformat" suffix, and erases the field if it's not correct.
*
* @return void
*/
protected function loadFormData()
{
$app = Factory::getApplication();
$filters = $app->getUserState($this->context . '.filter', array());
$error_dateformat = false;
foreach ($filters as $key => $value)
{
if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null)
{
$filters[$key] = '';
$error_dateformat = true;
}
}
if ($error_dateformat)
{
$app->enqueueMessage(Text::_("COM_DVTR_EMPLOYEES_SEARCH_FILTER_DATE_FORMAT"), "warning");
$app->setUserState($this->context . '.filter', $filters);
}
return parent::loadFormData();
}
/**
* Checks if a given date is valid and in a specified format (YYYY-MM-DD)
*
* @param string $date Date to be checked
*
* @return bool
*/
private function isValidDate($date)
{
$date = str_replace('/', '-', $date);
return (date_create($date)) ? Factory::getDate($date)->format("Y-m-d") : null;
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Service;
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\Categories\Categories;
/**
* Content Component Category Tree
*
* @since 1.0.0
*/

View File

@@ -0,0 +1,153 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\Service;
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Component\Router\RouterViewConfiguration;
use Joomla\CMS\Component\Router\RouterView;
use Joomla\CMS\Component\Router\Rules\StandardRules;
use Joomla\CMS\Component\Router\Rules\NomenuRules;
use Joomla\CMS\Component\Router\Rules\MenuRules;
use Joomla\CMS\Factory;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Categories\CategoryInterface;
use Joomla\Database\DatabaseInterface;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\CMS\Component\ComponentHelper;
/**
* Class Dvtr_employeesRouter
*
*/
class Router extends RouterView
{
private $noIDs;
/**
* The category factory
*
* @var CategoryFactoryInterface
*
* @since 1.0.0
*/
private $categoryFactory;
/**
* The category cache
*
* @var array
*
* @since 1.0.0
*/
private $categoryCache = [];
public function __construct(SiteApplication $app, AbstractMenu $menu, CategoryFactoryInterface $categoryFactory, DatabaseInterface $db)
{
$params = ComponentHelper::getParams('com_dvtr_employees');
$this->noIDs = true; //(bool) $params->get('sef_ids');
$this->categoryFactory = $categoryFactory;
$employees = new RouterViewConfiguration('employees');
$this->registerView($employees);
$ccEmployee = new RouterViewConfiguration('employee');
$ccEmployee->setKey('id')->setParent($employees);
$this->registerView($ccEmployee);
parent::__construct($app, $menu);
$this->attachRule(new MenuRules($this));
$this->attachRule(new StandardRules($this));
$this->attachRule(new NomenuRules($this));
}
/**
* Method to get the segment(s) for an employee
*
* @param string $id ID of the employee to retrieve the segments for
* @param array $query The request that is built right now
*
* @return array|string The segments of this item
*/
public function getEmployeeSegment($id, $query)
{
if (!strpos($id, ':'))
{
$db = Factory::getContainer()->get('DatabaseDriver');
$dbquery = $db->getQuery(true);
$dbquery->select($dbquery->qn('alias'))
->from($dbquery->qn('#__employees_'))
->where('id = ' . $dbquery->q($id));
$db->setQuery($dbquery);
$id .= ':' . $db->loadResult();
}
if ($this->noIDs)
{
list($void, $segment) = explode(':', $id, 2);
return array($void => $segment);
}
return array((int) $id => $id);
}
/**
* Method to get the segment(s) for an employee
*
* @param string $segment Segment of the employee to retrieve the ID for
* @param array $query The request that is parsed right now
*
* @return mixed The id of this item or false
*/
public function getEmployeeId($segment, $query)
{
if ($this->noIDs)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$dbquery = $db->getQuery(true);
$dbquery->select($dbquery->qn('id'))
->from($dbquery->qn('#__employees_'))
->where('alias = ' . $dbquery->q($segment));
$db->setQuery($dbquery);
return (int) $db->loadResult();
}
return (int) $segment;
}
/**
* Method to get categories from cache
*
* @param array $options The options for retrieving categories
*
* @return CategoryInterface The object containing categories
*
* @since 1.0.0
*/
private function getCategories(array $options = []): CategoryInterface
{
$key = serialize($options);
if (!isset($this->categoryCache[$key]))
{
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
}
return $this->categoryCache[$key];
}
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\View\Employee;
// No direct access
defined( '_JEXEC' ) or die;
use Exception;
use JFactory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
/**
* View class for a list of Dvtr_employees.
*
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView {
protected $state;
protected $item;
protected $form;
protected $params;
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*
* @throws Exception
*/
public function display( $tpl = NULL ) {
$app = Factory::getApplication();
$user = $app->getIdentity();
$this->state = $this->get( 'State' );
$this->item = $this->get( 'Item' );
$this->params = $app->getParams( 'com_dvtr_employees' );
$doc = JFactory::getDocument();
$doc->addStylesheet( 'components/com_dvtr_employees/assets/grid.css' );
$doc->addStylesheet( 'components/com_dvtr_employees/assets/style.css' );
// Check for errors.
if ( count( $errors = $this->get( 'Errors' ) ) ) {
throw new Exception( implode( "\n", $errors ) );
}
if ( $this->_layout == 'edit' ) {
$authorised = $user->authorise( 'core.create', 'com_dvtr_employees' );
if ( $authorised !== TRUE ) {
throw new Exception( Text::_( 'JERROR_ALERTNOAUTHOR' ) );
}
}
$this->_prepareDocument();
parent::display( $tpl );
}
/**
* Prepares the document
*
* @return void
*
* @throws Exception
*/
protected function _prepareDocument() {
$app = Factory::getApplication();
$menus = $app->getMenu();
$title = NULL;
// Because the application sets a default page title,
// We need to get it from the menu item itself
$menu = $menus->getActive();
if ( $menu ) {
$this->params->def( 'page_heading', $this->params->get( 'page_title', $menu->title ) );
} else {
$this->params->def( 'page_heading', Text::_( 'COM_DVTR_EMPLOYEES_DEFAULT_PAGE_TITLE' ) );
}
$title = $this->item->title ?? $this->params->get( 'page_title', '' );
if ( empty( $title ) ) {
$title = $app->get( 'sitename' );
} elseif ( $app->get( 'sitename_pagetitles', 0 ) == 1 ) {
$title = Text::sprintf( 'JPAGETITLE', $app->get( 'sitename' ), $title );
} elseif ( $app->get( 'sitename_pagetitles', 0 ) == 2 ) {
$title = Text::sprintf( 'JPAGETITLE', $title, $app->get( 'sitename' ) );
}
$this->document->setTitle( $title );
if ( $this->params->get( 'menu-meta_description' ) ) {
$this->document->setDescription( $this->params->get( 'menu-meta_description' ) );
}
if ( $this->params->get( 'menu-meta_keywords' ) ) {
$this->document->setMetadata( 'keywords', $this->params->get( 'menu-meta_keywords' ) );
}
if ( $this->params->get( 'robots' ) ) {
$this->document->setMetadata( 'robots', $this->params->get( 'robots' ) );
}
// Add Breadcrumbs
$pathway = $app->getPathway();
$breadcrumbList = Text::_( 'COM_DVTR_EMPLOYEES_TITLE_EMPLOYEES' );
if ( ! in_array( $breadcrumbList, $pathway->getPathwayNames() ) ) {
$pathway->addItem( $breadcrumbList, "index.php?option=com_dvtr_employees&view=employees" );
}
$breadcrumbTitle = Text::_( 'COM_DVTR_EMPLOYEES_TITLE_EMPLOYEE' );
if ( ! in_array( $breadcrumbTitle, $pathway->getPathwayNames() ) ) {
$pathway->addItem( $breadcrumbTitle );
}
}
}

View File

@@ -0,0 +1,148 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
namespace Dvtremployees\Component\Dvtr_employees\Site\View\Employees;
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Text;
/**
* View class for a list of Dvtr_employees.
*
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView
{
protected $items;
protected $pagination;
protected $state;
protected $params;
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*
* @throws Exception
*/
public function display($tpl = null)
{
$app = Factory::getApplication();
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $app->getParams('com_dvtr_employees');
$doc = \JFactory::getDocument();
$doc->addStylesheet( 'components/com_dvtr_employees/assets/grid.css');
$doc->addStylesheet( 'components/com_dvtr_employees/assets/style.css');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new \Exception(implode("\n", $errors));
}
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
*
* @throws Exception
*/
protected function _prepareDocument()
{
$app = Factory::getApplication();
$menus = $app->getMenu();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', Text::_('COM_DVTR_EMPLOYEES_DEFAULT_PAGE_TITLE'));
}
$title = $this->params->get('page_title', '');
if (empty($title))
{
$title = $app->get('sitename');
}
elseif ($app->get('sitename_pagetitles', 0) == 1)
{
$title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $title);
}
elseif ($app->get('sitename_pagetitles', 0) == 2)
{
$title = Text::sprintf('JPAGETITLE', $title, $app->get('sitename'));
}
$this->document->setTitle($title);
if ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
// Add Breadcrumbs
$pathway = $app->getPathway();
$breadcrumbTitle = Text::_('COM_DVTR_EMPLOYEES_TITLE_EMPLOYEES');
if(!in_array($breadcrumbTitle, $pathway->getPathwayNames())) {
$pathway->addItem($breadcrumbTitle);
}
}
/**
* Check if state is set
*
* @param mixed $state State
*
* @return bool
*/
public function getState($state)
{
return isset($this->state->{$state}) ? $this->state->{$state} : false;
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\HTML\HTMLHelper;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Uri\Uri;
use \Joomla\CMS\Router\Route;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Session\Session;
use Joomla\Utilities\ArrayHelper;
?>
<div class="container">
<div class="row">
<div class="col-8">
<!--<div class="name">
<h1><?php /*echo $this->item->name; */?> </h1>
</div>-->
<div class="desc">
<?php
echo JHtml::_('content.prepare', $this->item->description);
?>
</div>
<div class="publications">
<?php
echo JHtml::_('content.prepare', $this->item->publications);
?>
</div>
</div>
<div class="col-4">
<div class="avatar">
<img src="<?php echo $this->item->avatar ? $this->item->avatar : '/images/O%20instytucie/avatar.png'; ?>" alt="avatar"/>
</div>
<div class="name">
<strong><?php echo $this->item->name; ?></strong>
</div>
<!-- <div class="url">
<?php /*if(!empty($this->item->url)):*/?>
<a href="<?php /*echo $this->item->url */?>">
<?php /*echo $this->item->url */?>
</a>
<?php /*endif;*/?>
</div>-->
<div class="contact_data">
<?php
echo JHtml::_('content.prepare', $this->item->contact_data);
?>
</div>
<div class="achievements">
<strong><?php echo $this->item->achievements_label;?></strong><br/>
<?php
echo JHtml::_('content.prepare', $this->item->achievements);
?>
</div>
<div class="social-media">
<?php if(!empty($this->item->social_linkedin)):?>
<a href="<?php echo $this->item->social_linkedin ?>">
<!-- <i class="fa fa-linkedin"></i>-->
<img src="/media/com_quantummanager/images/icons/action/linkedin-logo.svg"/>
</a>
<?php endif;?>
<?php if(!empty($this->item->social_facebook)):?>
<a href="<?php echo $this->item->social_facebook ?>">
<!-- <i class="fa fa-facebook"></i>-->
<img src="/media/com_quantummanager/images/icons/action/facebook-logo.svg"/>
</a>
<?php endif;?>
<?php if(!empty($this->item->social_instagram)):?>
<a href="<?php echo $this->item->social_instagram ?>">
<!-- <i class="fa fa-facebook"></i>-->
<img src="/media/com_quantummanager/images/icons/action/instagram-logo.svg"/>
</a>
<?php endif;?>
<?php if(!empty($this->item->social_twitter)):?>
<a href="<?php echo $this->item->social_twitter ?>">
<!-- <i class="fa fa-facebook"></i>-->
<img src="/media/com_quantummanager/images/icons/action/twitter-logo-on-black-background.svg"/>
</a>
<?php endif;?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_DVTR_EMPLOYEES_TITLE_ITEM_VIEW_EMPLOYEE" option="View">
<message>
<![CDATA[COM_DVTR_EMPLOYEES_TITLE_ITEM_VIEW_EMPLOYEE_DESC]]>
</message>
</layout>
<fields name="request">
<fieldset
name="request"
label="COM_DVTR_EMPLOYEES_FIELDSET_ITEM_ID_SELECT_LABEL">
<field
name="id"
query="SELECT `id`, `name` FROM #__employees_ ORDER BY `id`"
type="sql"
key_field="id"
value_field="name"
label="COM_DVTR_EMPLOYEES_ITEM_ID_SELECT_LABEL"
require="true"
description="JGLOBAL_SHOW_TITLE_DESC">
</field>
</fieldset>
</fields>
</metadata>

View File

@@ -0,0 +1 @@
<html><body></body></html>

View File

@@ -0,0 +1,144 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Dvtr_employees
* @author Pawel Potoniec <pawel@devatri.pl>
* @copyright 2025 Pawel Potoniec
*/
// No direct access
defined( '_JEXEC' ) or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Session\Session;
use Joomla\CMS\User\UserFactoryInterface;
HTMLHelper::_( 'bootstrap.tooltip' );
HTMLHelper::_( 'behavior.multiselect' );
HTMLHelper::_( 'formbehavior.chosen', 'select' );
$user = Factory::getApplication()->getIdentity();
$userId = $user->get( 'id' );
$listOrder = $this->state->get( 'list.ordering' );
$listDirn = $this->state->get( 'list.direction' );
$canCreate = $user->authorise( 'core.create', 'com_dvtr_employees' ) && file_exists( JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'employeeform.xml' );
$canEdit = $user->authorise( 'core.edit', 'com_dvtr_employees' ) && file_exists( JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'employeeform.xml' );
$canCheckin = $user->authorise( 'core.manage', 'com_dvtr_employees' );
$canChange = $user->authorise( 'core.edit.state', 'com_dvtr_employees' );
$canDelete = $user->authorise( 'core.delete', 'com_dvtr_employees' );
$wa = $this->document->getWebAssetManager();
$wa->useStyle( 'com_dvtr_employees.list' );
foreach ( $this->items as $item ) :
$item->introtext = $item->description ?? '';
$item->title = $item->name ?? 'Pracownik';
$item->created = $item->created ?? date( 'Y-m-d H:i:s' );
echo LayoutHelper::render( 'joomla.content.article', [
'item' => $item,
'params' => $this->params,
] );
endforeach;
?>
<?php if ( $this->params->get( 'show_page_heading' ) ) : ?>
<div class="page-header">
<h1> <?php echo $this->escape( $this->params->get( 'page_heading' ) ); ?> </h1>
</div>
<?php endif; ?>
<form action="<?php echo htmlspecialchars( Uri::getInstance()->toString() ); ?>" method="post"
name="adminForm" id="adminForm">
<div class="row">
<h1><?php echo Text::_('COM_DVTR_EMPLOYEES_TITLE_EMPLOYEES');?></h1>
<?php foreach ( $this->items as $i => $item ) : ?>
<?php $canEdit = $user->authorise( 'core.edit', 'com_dvtr_employees' ); ?>
<div class="col-3 index-<?php echo $i % 3; ?>">
<!-- <td>-->
<!-- --><?php //echo $item->id; ?>
<!-- </td>-->
<div class="employee-avatar">
<a href="<?php echo Route::_( 'index.php?option=com_dvtr_employees&view=employee&id=' . (int) $item->id ); ?>">
<img src="<?php echo $item->avatar ? $item->avatar : '/images/O%20instytucie/avatar.png'; ?>" alt="avatar"/>
</a>
</div>
<div class="employee-name">
<?php echo $item->name; ?>
</div>
<div class="social-media">
<?php if(!empty($item->social_linkedin)):?>
<a href="<?php echo $item->social_linkedin ?>">
<!-- <i class="fa fa-linkedin"></i>-->
<img src="/media/com_quantummanager/images/icons/action/linkedin-logo.svg"/>
</a>
<?php endif;?>
<?php if(!empty($item->social_facebook)):?>
<a href="<?php echo $item->social_facebook ?>">
<!-- <i class="fa fa-facebook"></i>-->
<img src="/media/com_quantummanager/images/icons/action/facebook-logo.svg"/>
</a>
<?php endif;?>
<?php if(!empty($item->social_instagram)):?>
<a href="<?php echo $item->social_instagram ?>">
<!-- <i class="fa fa-facebook"></i>-->
<img src="/media/com_quantummanager/images/icons/action/instagram-logo.svg"/>
</a>
<?php endif;?>
<?php if(!empty($item->social_twitter)):?>
<a href="<?php echo $item->social_twitter ?>">
<!-- <i class="fa fa-facebook"></i>-->
<img src="/media/com_quantummanager/images/icons/action/twitter-logo-on-black-background.svg"/>
</a>
<?php endif;?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ( $canCreate ) : ?>
<a href="<?php echo Route::_( 'index.php?option=com_dvtr_employees&task=employeeform.edit&id=0', FALSE, 0 ); ?>"
class="btn btn-success btn-small"><i
class="icon-plus"></i>
<?php echo Text::_( 'COM_DVTR_EMPLOYEES_ADD_ITEM' ); ?></a>
<?php endif; ?>
<input type="hidden" name="task" value=""/>
<input type="hidden" name="boxchecked" value="0"/>
<input type="hidden" name="filter_order" value=""/>
<input type="hidden" name="filter_order_Dir" value=""/>
<?php echo HTMLHelper::_( 'form.token' ); ?>
</form>
<?php
if ( $canDelete ) {
$wa->addInlineScript( "
jQuery(document).ready(function () {
jQuery('.delete-button').click(deleteItem);
});
function deleteItem() {
if (!confirm(\"" . Text::_( 'COM_DVTR_EMPLOYEES_DELETE_MESSAGE' ) . "\")) {
return false;
}
}
", [], [], [ "jquery" ] );
}
?>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_DVTR_EMPLOYEES_TITLE_LIST_VIEW_EMPLOYEES" option="View">
<message>
<![CDATA[COM_DVTR_EMPLOYEES_TITLE_LIST_VIEW_EMPLOYEES_DESC]]>
</message>
</layout>
</metadata>

View File

@@ -0,0 +1 @@
<html><body></body></html>