Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
astridx committed Dec 31, 2021
1 parent 4b39c80 commit 0fc866f
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 193 deletions.
21 changes: 21 additions & 0 deletions aggpxtrack-update4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,25 @@
<sha256></sha256>
<sha384></sha384>
</update>
<update>
<name>pkg_aggpxtrack</name>
<description>pkg_aggpxtrack</description>
<element>pkg_aggpxtrack</element>
<type>package</type>
<client>site</client>
<version>4.0.2</version>
<infourl title="aggpxtrack">https://github.com/astridx/pkg_aggpxtrack/blob/v4.0.2/README.md</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/astridx/pkg_aggpxtrack/releases/download/v4.0.2/pkg-aggpxtrack-4.0.2.zip</downloadurl>
</downloads>
<tags>
<tag>rc</tag>
<tag>stable</tag>
</tags>
<maintainer>Astrid Günther</maintainer>
<maintainerurl>https://astrid-guenther.de</maintainerurl>
<targetplatform name="joomla" version="4.0.0"/>
<sha256></sha256>
<sha384></sha384>
</update>
</updates>
2 changes: 1 addition & 1 deletion j4/pkg_aggpxtrack/jorobo.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extension = aggpxtrack
version = 4.0.1
version = 4.0.2
source = src
target = package

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
define('COM_MEDIA_BASE', JPATH_ROOT . '/' . $params->get($path, 'images'));
define('COM_MEDIA_BASEURL', JUri::root() . $params->get($path, 'images'));

$controller = JControllerLegacy::getInstance('Aggpxtrack', array('base_path' => JPATH_COMPONENT_ADMINISTRATOR));
$controller = JControllerLegacy::getInstance('Aggpxtrack', ['base_path' => JPATH_COMPONENT_ADMINISTRATOR]);
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AggpxtrackController extends JControllerLegacy
*
* @since 1.5
*/
public function display($cacheable = false, $urlparams = array())
public function display($cacheable = false, $urlparams = [])
{
return parent::display();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,19 @@ public function upload()
$this->folder = $this->input->get('folder', '', 'path');

// Don't redirect to an external URL.
if (!JUri::isInternal($return))
{
if (!JUri::isInternal($return)) {
$return = '';
}

// Set the redirect
if ($return)
{
if ($return) {
$this->setRedirect($return . '&folder=' . $this->folder);
}
else
{
} else {
$this->setRedirect('index.php?option=com_aggpxtrack&folder=' . $this->folder);
}

// Authorize the user
if (!$this->authoriseUser('create'))
{
if (!$this->authoriseUser('create')) {
return false;
}

Expand All @@ -81,8 +76,7 @@ public function upload()

// Check for the total size of post back data.
if (($postMaxSize > 0 && $contentLength > $postMaxSize)
|| ($memoryLimit != -1 && $contentLength > $memoryLimit))
{
|| ($memoryLimit != -1 && $contentLength > $memoryLimit)) {
$app->enqueueMessage(JText::_('COM_AGGPXTRACK_ERROR_WARNUPLOADTOOLARGE'), 'warning');

return false;
Expand All @@ -92,32 +86,28 @@ public function upload()
$uploadMaxFileSize = $mediaHelper->toBytes(ini_get('upload_max_filesize'));

// Perform basic checks on file info before attempting anything
foreach ($files as &$file)
{
foreach ($files as &$file) {
$file['name'] = JFile::makeSafe($file['name']);
$file['name'] = str_replace(' ', '-', $file['name']);
$file['filepath'] = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $this->folder, $file['name'])));
$file['filepath'] = JPath::clean(implode(DIRECTORY_SEPARATOR, [COM_MEDIA_BASE, $this->folder, $file['name']]));

if (($file['error'] == 1)
|| ($uploadMaxSize > 0 && $file['size'] > $uploadMaxSize)
|| ($uploadMaxFileSize > 0 && $file['size'] > $uploadMaxFileSize))
{
|| ($uploadMaxFileSize > 0 && $file['size'] > $uploadMaxFileSize)) {
// File size exceed either 'upload_max_filesize' or 'upload_maxsize'.
$app->enqueueMessage(JText::_('COM_AGGPXTRACK_ERROR_WARNFILETOOLARGE'), 'warning');

return false;
}

if (JFile::exists($file['filepath']))
{
if (JFile::exists($file['filepath'])) {
// A file with this name already exists
$app->enqueueMessage(JText::_('COM_AGGPXTRACK_ERROR_FILE_EXISTS'), 'warning');

return false;
}

if (!isset($file['name']))
{
if (!isset($file['name'])) {
// No filename (after the name was cleaned by JFile::makeSafe)
$this->setRedirect('index.php', JText::_('COM_AGGPXTRACK_INVALID_REQUEST'), 'error');

Expand All @@ -130,24 +120,21 @@ public function upload()
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();

foreach ($files as &$file)
{
foreach ($files as &$file) {
// The request is valid
$ext = 'com_media';

if (!$mediaHelper->canUpload($file, $ext))
{
if (!$mediaHelper->canUpload($file, $ext)) {
// The file can't be uploaded

return false;
}

// Trigger the onContentBeforeSave event.
$object_file = new JObject($file);
$result = $dispatcher->trigger('onContentBeforeSave', array('com_aggpxtrack.file', &$object_file, true));
$result = $dispatcher->trigger('onContentBeforeSave', ['com_aggpxtrack.file', &$object_file, true]);

if (in_array(false, $result, true))
{
if (in_array(false, $result, true)) {
// There are some errors in the plugins
$app->enqueueMessage(
JText::plural('COM_AGGPXTRACK_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)),
Expand All @@ -157,16 +144,15 @@ public function upload()
return false;
}

if (!JFile::upload($object_file->tmp_name, $object_file->filepath))
{
if (!JFile::upload($object_file->tmp_name, $object_file->filepath)) {
// Error in upload
$app->enqueueMessage(JText::_('COM_AGGPXTRACK_ERROR_UNABLE_TO_UPLOAD_FILE'), 'warning');

return false;
}

// Trigger the onContentAfterSave event.
$dispatcher->trigger('onContentAfterSave', array('com_aggpxtrack.file', &$object_file, true));
$dispatcher->trigger('onContentAfterSave', ['com_aggpxtrack.file', &$object_file, true]);
$this->setMessage(JText::sprintf('COM_AGGPXTRACK_UPLOAD_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}

Expand All @@ -184,8 +170,7 @@ public function upload()
*/
protected function authoriseUser($action)
{
if (!JFactory::getUser()->authorise('core.' . strtolower($action), 'com_aggpxtrack'))
{
if (!JFactory::getUser()->authorise('core.' . strtolower($action), 'com_aggpxtrack')) {
// User is not authorised
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_' . strtoupper($action) . '_NOT_PERMITTED'), 'warning');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function getState($property = null, $default = null)
{
static $set;

if (!$set)
{
if (!$set) {
$input = JFactory::getApplication()->input;
$folder = $input->get('folder', '', 'path');
$this->setState('folder', $folder);
Expand Down Expand Up @@ -89,8 +88,7 @@ public function getList()
static $list;

// Only process the list once per request
if (is_array($list))
{
if (is_array($list)) {
return $list;
}

Expand All @@ -100,26 +98,22 @@ public function getList()
$basePath = COM_MEDIA_BASE . ((strlen($current) > 0) ? '/' . $current : '');
$mediaBase = str_replace(DIRECTORY_SEPARATOR, '/', COM_MEDIA_BASE . '/');

$images = array ();
$folders = array ();
$images = [];
$folders = [];

$fileList = false;
$folderList = false;

if (file_exists($basePath))
{
if (file_exists($basePath)) {
// Get the list of files and folders from the given folder
$fileList = array_reverse(JFolder::files($basePath));
$folderList = JFolder::folders($basePath);
}

// Iterate over the files if they exist
if ($fileList !== false)
{
foreach ($fileList as $file)
{
if (is_file($basePath . '/' . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html')
{
if ($fileList !== false) {
foreach ($fileList as $file) {
if (is_file($basePath . '/' . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
$tmp = new JObject;
$tmp->name = $file;
$tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $file));
Expand All @@ -129,19 +123,16 @@ public function getList()

$file_extension = strtolower(JFile::getExt($file));

if ($file_extension == 'gpx')
{
if ($file_extension == 'gpx') {
$images[] = $tmp;
}
}
}
}

// Iterate over the folders if they exist
if ($folderList !== false)
{
foreach ($folderList as $folder)
{
if ($folderList !== false) {
foreach ($folderList as $folder) {
$tmp = new JObject;
$tmp->name = basename($folder);
$tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $folder));
Expand All @@ -156,16 +147,15 @@ public function getList()
}

// Sortiert nach Datum
$date = array();
$date = [];

foreach ($images as $key => $row)
{
foreach ($images as $key => $row) {
$date[$key] = $row->date;
}

array_multisort($date, SORT_DESC, $images);

$list = array('folders' => $folders, 'images' => $images);
$list = ['folders' => $folders, 'images' => $images];

return $list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ public function copyFiles()
// Now we read all png files and put them in an array.
$gpx_files = JFolder::files($pathsearch, '.gpx');

foreach ($gpx_files as $file)
{
if (!file_exists($path . $file))
{
foreach ($gpx_files as $file) {
if (!file_exists($path . $file)) {
JFile::copy($pathsearch . $file, $path . $file);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ public function display($tpl = null)
{
$url = JUri::base() . $url;
header('Location: ' . $url . 'index.php?option=com_config');

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
JHtml::_('formbehavior.chosen', 'select');

// Load tooltip instance without HTML support because we have a HTML tag in the tip
JHtml::_('bootstrap.tooltip', '.noHtmlTip', array('html' => false));
JHtml::_('bootstrap.tooltip', '.noHtmlTip', ['html' => false]);

// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'com_aggpxtrack/popup-manager.js', false, true, false, false, true);
JHtml::_('stylesheet', 'media/popup-imagemanager.css', array(), true);
JHtml::_('stylesheet', 'media/popup-imagemanager.css', [], true);

if ($lang->isRtl())
{
JHtml::_('stylesheet', 'media/popup-imagemanager_rtl.css', array(), true);
if ($lang->isRtl()) {
JHtml::_('stylesheet', 'media/popup-imagemanager_rtl.css', [], true);
}

JFactory::getDocument()->addScriptDeclaration(
Expand All @@ -47,14 +46,11 @@
*
* This should be removed when mootools won't be shipped by Joomla.
*/
if (!empty($fieldInput)) // Media Form Field
{
if ($isMoo)
{
if (!empty($fieldInput)) { // Media Form Field
if ($isMoo) {
$onClick = "window.parent.jInsertFieldValue(document.getElementById('f_url').value, '" . $fieldInput . "');window.parent.jModalClose();window.parent.jQuery('.modal.in').modal('hide');";
}
}
else // XTD Image plugin
} else // XTD Image plugin
{
$onClick = 'ImageManager.onok();window.parent.jModalClose();';
}
Expand All @@ -64,7 +60,7 @@
<form action="index.php?option=com_media&amp;asset=<?php echo $input->getCmd('asset');?>&amp;author=<?php echo $input->getCmd('author'); ?>" class="form-vertical" id="imageForm" method="post" enctype="multipart/form-data">

<div id="messages" style="display: none;">
<span id="message"></span><?php echo JHtml::_('image', 'media/dots.gif', '...', array('width' => 22, 'height' => 12), true) ?>
<span id="message"></span><?php echo JHtml::_('image', 'media/dots.gif', '...', ['width' => 22, 'height' => 12], true) ?>
</div>

<div class="well">
Expand All @@ -81,7 +77,8 @@
</div>
<div class="pull-right">
<button class="btn btn-success button-save-selected" type="button" <?php if (!empty($onClick)) :
// This is for Mootools compatibility ?>onclick="<?php echo $onClick; ?>"<?php endif; ?> data-dismiss="modal"><?php echo JText::_('COM_AGGPXTRACK_INSERT'); ?></button>
// This is for Mootools compatibility ?>onclick="<?php echo $onClick; ?>"<?php
endif; ?> data-dismiss="modal"><?php echo JText::_('COM_AGGPXTRACK_INSERT'); ?></button>
<button class="btn button-cancel" type="button" onclick="window.parent.jModalClose();" data-dismiss="modal"><?php echo JText::_('JCANCEL'); ?></button>
</div>
</div>
Expand All @@ -100,7 +97,7 @@
</div>
</div>
</div>
<?php if (!$this->state->get('field.id')):?>
<?php if (!$this->state->get('field.id')) :?>
<div class="row">
<div class="span6 control-group">
<div class="control-label">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

$params = new Registry;
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentBeforeDisplay', array('com_aggpxtrack.file', &$this->_tmp_img, &$params));
$dispatcher->trigger('onContentBeforeDisplay', ['com_aggpxtrack.file', &$this->_tmp_img, &$params]);
?>

<li class="imgOutline thumbnail height-80 width-80 center">
Expand All @@ -29,4 +29,4 @@
</a>
</li>
<?php
$dispatcher->trigger('onContentAfterDisplay', array('com_aggpxtrack.file', &$this->_tmp_img, &$params));
$dispatcher->trigger('onContentAfterDisplay', ['com_aggpxtrack.file', &$this->_tmp_img, &$params]);
Loading

0 comments on commit 0fc866f

Please sign in to comment.