Skip to content

Commit

Permalink
4.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
PhocaCz committed Oct 20, 2023
1 parent a0d8b94 commit 26a028c
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
26 changes: 26 additions & 0 deletions admin/libraries/phocadownload/category/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class PhocaDownloadCategory
{

private static $categoriesCache = null;
private static $categoryA = array();
private static $categoryF = array();
private static $categoryP = array();
Expand Down Expand Up @@ -245,5 +246,30 @@ public static function getPathTree($path = array(), $id = 0, $parent_id = 0, $ti
}
return $path;
}


private static function loadCategoriesCache(): void {
if (self::$categoriesCache === null) {
$db = Factory::getDBO();
$db->setQuery('SELECT a.*, null AS children FROM #__phocadownload_categories AS a ORDER BY a.ordering, a.id');
$categories = $db->loadObjectList('id') ?? [];

array_walk($categories, function ($category) use ($categories) {
if ($category->parent_id) {
if ($categories[$category->parent_id]->children === null)
$categories[$category->parent_id]->children = [];
$categories[$category->parent_id]->children[] = $category;
}
});

self::$categoriesCache = $categories;
}
}

public static function getCategories(): array {
self::loadCategoriesCache();

return self::$categoriesCache;
}
}
?>
80 changes: 78 additions & 2 deletions admin/libraries/phocadownload/html/batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;

abstract class PhocaDownloadBatch
{

public static function item($published, $category = 0)
/*public static function item($published, $category = 0)
{
// Create the copy/move options.
$options = array(
Expand Down Expand Up @@ -50,13 +51,88 @@ public static function item($published, $category = 0)
'<fieldset id="batch-choose-action" class="combo">',
'<select name="batch[category_id]" class="form-control" id="batch-category-id">',
'<option value=""> - '.Text::_('JSELECT').' - </option>',
/*JHtml::_('select.options', JHtml::_('category.options', $extension, array('published' => (int) $published))),*/
/*JHtml::_('select.options', JHtml::_('category.options', $extension, array('published' => (int) $published))),*//*
HTMLHelper::_('select.options', $tree ),
'</select>',
HTMLHelper::_( 'select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'),
'</fieldset>'
);
return implode("\n", $lines);
}
*/

private static function buildCategoryTree(array &$options, array $categories, string $treeTitle): void {
foreach ($categories as $category) {
$title = ($treeTitle ? $treeTitle . ' - ' : '') . $category->title;
$options[] = (object)[
'text' => $title . ($category->language === '*' ? '' : ' (' . $category->language . ')'),
'value' => $category->id,
];
if ($category->children)
self::buildCategoryTree($options, $category->children, $title);
}
}

public static function item($published, $category = 0)
{
// Create the copy/move options.
$options = array(
HTMLHelper::_('select.option', 'c', Text::_('JLIB_HTML_BATCH_COPY')),
HTMLHelper::_('select.option', 'm', Text::_('JLIB_HTML_BATCH_MOVE'))
);

$rootCategories = array_filter(PhocadownloadCategory::getCategories(), function($category) {
return !$category->parent_id;
});

$tree = [];
$tree[] = HTMLHelper::_('select.option', '', Text::_('JSELECT'), 'value', 'text');
if ($category) {
$tree[] = HTMLHelper::_('select.option', 0, Text::_('JLIB_HTML_ADD_TO_ROOT'), 'value', 'text');
}
self::buildCategoryTree($tree, $rootCategories, '');

$fancySelectData = [
'autocomplete' => 'off',
'autofocus' => false,
'class' => '',
'description' => '',
'disabled' => false,
'group' => false,
'id' => 'batch-category-id',
'hidden' => false,
'hint' => '',
'label' => '',
'labelclass' => '',
'onchange' => '',
'onclick' => '',
'multiple' => false,
'pattern' => '',
'readonly' => false,
'repeat' => false,
'required' => false,
'size' => 4,
'spellcheck' => false,
'validate' => '',
'value' => '',
'options' => $tree,
'dataAttributes' => [],
'dataAttribute' => '',
'name' => 'batch[category_id]',
];

// Create the batch selector to change select the category by which to move or copy.
$lines = array(
'<label id="batch-choose-action-lbl" for="batch-choose-action">',
Text::_('JLIB_HTML_BATCH_MENU_LABEL'),
'</label>',
'<fieldset id="batch-choose-action" class="combo">',
LayoutHelper::render('joomla.form.field.list-fancy-select', $fancySelectData),
HTMLHelper::_( 'select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'),
'</fieldset>'
);

return implode("\n", $lines);
}
}
Expand Down
2 changes: 1 addition & 1 deletion checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"com_phocadownload_v5.0.0Beta.zip":{"key":"com_phocadownload_v5.0.0Beta.zip","extname":"com_phocadownload","version":"5.0.0Beta","checksum":"20941490400c5c7a3de22dcd565c5a71674d746bda0947409e17176ebbf5a91693893cd6fbd5b45c2e61d2658d4312fcaf5bf1269fd804ff36d3670cf536e3e8"},"com_phocadownload_v4.0.7.zip":{"key":"com_phocadownload_v4.0.7.zip","extname":"com_phocadownload","version":"4.0.7","checksum":"a0e91e9087d8fae4a0215c429391e6531f95bd6e62c84d667e7767bea44dbc3e020ee4800bdfbe7d36640c0b9b565984ad8af5b1f326608b788e5618679b8796"}}
{"com_phocadownload_v5.0.0Beta.zip":{"key":"com_phocadownload_v5.0.0Beta.zip","extname":"com_phocadownload","version":"5.0.0Beta","checksum":"60224eaec714795c831ccf2145be6272561bf62cb831a5f28ce2b738d894e3d9d24c2e3805e2d769e36d50cdb21ead28572a76f80de58271a2ad31cd9915c43d"},"com_phocadownload_v4.0.7.zip":{"key":"com_phocadownload_v4.0.7.zip","extname":"com_phocadownload","version":"4.0.7","checksum":"85092b0c0de78f23abb348f1083bd6de10e46f0cecfa50aa984fd84a67a9a2255cd6fcc30467b75a3ea545d81959520a9d11d86299c5f0a306ace8821d8c8e50"}}
4 changes: 3 additions & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<downloads>
<downloadurl type="full" format="zip">https://github.com/PhocaCz/PhocaDownload/releases/download/4.0.7/com_phocadownload_v4.0.7.zip</downloadurl>
</downloads>
<sha512>a0e91e9087d8fae4a0215c429391e6531f95bd6e62c84d667e7767bea44dbc3e020ee4800bdfbe7d36640c0b9b565984ad8af5b1f326608b788e5618679b8796</sha512>
<sha512>85092b0c0de78f23abb348f1083bd6de10e46f0cecfa50aa984fd84a67a9a2255cd6fcc30467b75a3ea545d81959520a9d11d86299c5f0a306ace8821d8c8e50</sha512>
<tags>
<tag>stable</tag>
</tags>
Expand All @@ -39,4 +39,6 @@
<targetplatform name="joomla" version="4\.*"/>
<client>administrator</client>
</update>
<update>

</updates>

0 comments on commit 26a028c

Please sign in to comment.