Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
Release: develop into main for v6 release

See merge request 2pisoftware/cosine/core!407
  • Loading branch information
iceaxeliehne committed Dec 11, 2024
2 parents 4007c5c + 46d2f6f commit 6c5ee06
Show file tree
Hide file tree
Showing 208 changed files with 9,616 additions and 5,937 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ jobs:
CORE_BRANCH: "${{ github.event.pull_request.head.ref || github.ref_name }}"
run: |
# Link system dir
cd core
git status
cd ..
cd boilerplate
ln -s ../core/system system
Expand Down Expand Up @@ -174,7 +177,7 @@ jobs:
docker cp cmfive:/var/www/html/system/templates/base /tmp/cmfive-theme
cd /tmp/cmfive-theme
npm ci || npm install
npm run production
npm run prod
# Copy the compiled theme back to the docker container
docker cp /tmp/cmfive-theme/. cmfive:/var/www/html/system/templates/base
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npm install
- name: Build
working-directory: ./system/templates/base
run: npm run production
run: npm run prod
- name: Save artifact
uses: actions/upload-artifact@v4
with:
Expand Down
18 changes: 12 additions & 6 deletions system/classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function set($key, $value)
* key out of the array
*
* @param string $key
* @return Mixed the value
* @return mixed the value
*/
public static function get($key, $default = null)
{
Expand Down Expand Up @@ -234,6 +234,15 @@ public static function setSandbox($shadow_register = [])
{
self::$shadow_register = $shadow_register;
}

public static function promoteSandbox()
{
if (self::isSandboxing()) {
if (!empty(self::$register)) {
self::$shadow_register = array_merge(self::$shadow_register, self::$register);
}
}
}

public static function mergeSandbox()
{
Expand Down Expand Up @@ -475,8 +484,8 @@ public static function registerModule($module, $config, $include_path)
/**
* Searches the dependency stack for a registered module
*
* @param String $module
* @return Mixed registered module
* @param string $module
* @return string|null registered module
*/
public static function getRegisteredModule($module)
{
Expand All @@ -496,9 +505,6 @@ public static function getRegisteredModule($module)
public static function load()
{
if (!empty(self::$dependency_stack)) {
// Remove - testing graph capabilities by randomising the load order of modules
shuffle(self::$dependency_stack);

foreach (self::$dependency_stack as $node) {
self::visitNode($node);
}
Expand Down
2 changes: 1 addition & 1 deletion system/classes/DbService.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function clearCache()
*
* @param string $table
* @param scalar|array $idOrWhere
* @return $class|null
* @return DbObject|null
*/
public function getObject($class, $idOrWhere, $use_cache = true, $order_by = null, $includeDeleted = false)
{
Expand Down
112 changes: 66 additions & 46 deletions system/classes/HtmlBootstrap5.php

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions system/classes/InjectableModuleInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

interface InjectableModuleInterface
{
/**
* This function should return a fake Config array that will be used to inject the module into the top menu.
* The injected_by key should be the name of the module that is injecting this module and is required for
* ensuring that the autoloader can find the right folder for autoloaded classes
*
* E.g.
* ```php
* return [
* 'path' => 'modules',
* 'active' => true,
* 'topmenu' => 'Injected Module',
* 'injected_by' => 'my_parent_module',
* ];
* ```
* @return array
*/
public static function serviceConfig(): array;

/**
* This function should inspect the parsed Web path and determine if the current request is in the injected top level module.
* This is primarily used to ensure that the correct top level menu item is highlighted correctly.
*
* E.g.
* ```php
* return $w->_module == "parent_module" && in_array($w->_submodule, ['injected_submodule1', 'injected_submodule2']);
* ```
* @param Web $w
* @return bool
*/
public static function isInInjectedTopLevelModule(Web $w): bool;

/**
* MenuLink is needed as the Web version of the menuLink function makes checks to Auth allowed functions that interfere with display
*
* E.g.
* ```php
* return HtmlBootstrap5::a("/my-module/target_action", "My Injected Module", null, 'nav-link');
* ```
* @return string
*/
public function menuLink(): string;
}
5 changes: 3 additions & 2 deletions system/classes/MenuLinkStruct.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

class MenuLinkStruct {
class MenuLinkStruct
{
public function __construct(
public string $title,
public string $url,
public MenuLinkType $type = MenuLinkType::Link,
) {
if ($url[0] !== '/') {
$this->url = '/' . $url;
$this->url = '/'.$url;
}
}
}
24 changes: 24 additions & 0 deletions system/classes/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,28 @@ public static function hasAll(string ...$keys): bool

return true;
}

/**
* Returns an array of all the parameters in the $_REQUEST superglobal. If a
* predicate is supplied, only the parameters that pass the predicate will be
* returned.
*
* @param callable|null $predicate
* @return array
*/
public static function params(callable $predicate = null): array
{
if (empty($predicate)) {
return $_REQUEST;
}

$params = [];
foreach ($_REQUEST as $key => $value) {
if ($predicate($key, $value)) {
$params[$key] = $value;
}
}

return $params;
}
}
12 changes: 0 additions & 12 deletions system/classes/html/cmfive/CodeMirrorEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,9 @@ public function setValues(array $values): self
$this->_values = $values;
return $this;
}
/*
public function __toString(): string
{
if (!empty($this->_values)) {
$this->_config['items'] = $this->_values;
}
$this->setAttribute('data-config', json_encode($this->_config));
$this->class = $this->class .= ' code-mirror-target';

return parent::__toString();
}
*/
public function __toString()
{
return '<textarea name="' . $this->name . '" id="' . $this->id . '" style="display:none"></textarea><div class="code-mirror-target" cm-value=\'' . $this->value . '\' id="' . $this->id . '">' . '</div>';
}

}
8 changes: 7 additions & 1 deletion system/classes/html/cmfive/QuillEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class QuillEditor extends \Html\Form\InputField

public $options = ["theme" => "snow"];

/**
* Value of the textarea
* @var string
*/
public $value;

/**
* Sets the options to use for Quill
*
Expand All @@ -25,6 +31,6 @@ public function setOptions(array $options = []): self

public function __toString()
{
return '<textarea name="' . $this->name . '" id="' . $this->id . '" style="display:none"></textarea><div class="quill-editor" data-quill-options=\'' . json_encode($this->options, JSON_FORCE_OBJECT) . '\' id="quill_' . $this->id . '">' . $this->value . '</div>';
return '<textarea name="' . $this->name . '" id="' . $this->id . '" style="display:none">' . $this->value . '</textarea><div class="quill-editor" data-quill-options=\'' . json_encode($this->options, JSON_FORCE_OBJECT) . '\' id="quill_' . $this->id . '">' . $this->value . '</div>';
}
}
46 changes: 46 additions & 0 deletions system/classes/html/cmfive/TabbedPagination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Html\Cmfive;

use HtmlBootstrap5;

/**
* UI helper for enabling multiple pagination controls on a page, all dynamic
* interaction handled by templates/base/src/js/components/TabbedPagination.ts
*/
class TabbedPagination extends \Html\Element
{
private array $_pages = [];
private string $_tab = '';

public function setPages(array $pages): self
{
$this->_pages = $pages;
return $this;
}

public function setTab(string $tab): self
{
$this->_tab = $tab;
return $this;
}

public function __toString(): string
{
$pages = '';
$page_number = 1;
foreach ($this->_pages as $page) {
$hidden = $page_number > 1 ? 'd-none' : '';
$pages .= "<div class='$hidden' data-page-number='$page_number'>$page</div>";

$page_number++;
}

$controls = HtmlBootstrap5::pagination(1, count($this->_pages), null, null, null, tab: $this->_tab);

return "<div id='$this->_tab-tabbed-pagination'>
$pages
$controls
</div>";
}
}
11 changes: 10 additions & 1 deletion system/classes/html/form/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Banner extends \Html\Form\FormElement
public $name;
public $value;

public $type = "warning";

static $_excludeFromOutput = ["value"];

/**
Expand All @@ -27,7 +29,7 @@ class Banner extends \Html\Form\FormElement
*/
public function __toString()
{
$buffer = ' <div class="alert alert-warning" role="alert" ';
$buffer = '<div class="alert alert-' . $this->type . '" role="alert" ';

foreach (get_object_vars($this) as $field => $value) {
if (!is_null($value) && !is_array($this->{$field}) && !in_array($field, static::$_excludeFromOutput)) {
Expand Down Expand Up @@ -63,4 +65,11 @@ public function setValue($value)

return $this;
}

public function setType($type)
{
$this->type = $type;

return $this;
}
}
7 changes: 7 additions & 0 deletions system/classes/html/form/CheckboxGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class CheckboxGroup extends InputField
public $checkbox_values = [];
public $selected_values = [];

public function setCheckboxValues(array $checkbox_values, array $selected_values)
{
$this->checkbox_values = $checkbox_values;
$this->selected_values = $selected_values;
return $this;
}

public static $_excludeFromOutput = [
'checkbox_values',
'selected_values'
Expand Down
Loading

0 comments on commit 6c5ee06

Please sign in to comment.