tagert blank & background flex
This commit is contained in:
@@ -125,7 +125,7 @@ abstract class BaseAsset extends PropertyObject
|
||||
if ($locator->isStream($asset)) {
|
||||
$path = $locator->findResource($asset, true);
|
||||
} else {
|
||||
$path = GRAV_ROOT . $asset;
|
||||
$path = GRAV_WEBROOT . $asset;
|
||||
}
|
||||
|
||||
// If local file is missing return
|
||||
@@ -172,15 +172,14 @@ abstract class BaseAsset extends PropertyObject
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Receive asset location and return the SRI integrity hash
|
||||
*
|
||||
* @param $input
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
public static function integrityHash( $input )
|
||||
public static function integrityHash($input)
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
@@ -188,7 +187,7 @@ abstract class BaseAsset extends PropertyObject
|
||||
|
||||
if ( !empty($assetsConfig['enable_asset_sri']) && $assetsConfig['enable_asset_sri'] )
|
||||
{
|
||||
$dataToHash = file_get_contents( GRAV_ROOT . $input);
|
||||
$dataToHash = file_get_contents( GRAV_WEBROOT . $input);
|
||||
|
||||
$hash = hash('sha256', $dataToHash, true);
|
||||
$hash_base64 = base64_encode($hash);
|
||||
@@ -209,7 +208,7 @@ abstract class BaseAsset extends PropertyObject
|
||||
*/
|
||||
// protected function getLastModificationTime($asset)
|
||||
// {
|
||||
// $file = GRAV_ROOT . $asset;
|
||||
// $file = GRAV_WEBROOT . $asset;
|
||||
// if (Grav::instance()['locator']->isStream($asset)) {
|
||||
// $file = $this->buildLocalLink($asset, true);
|
||||
// }
|
||||
@@ -228,7 +227,7 @@ abstract class BaseAsset extends PropertyObject
|
||||
protected function buildLocalLink($asset)
|
||||
{
|
||||
if ($asset) {
|
||||
return $this->base_url . ltrim(Utils::replaceFirstOccurrence(GRAV_ROOT, '', $asset), '/');
|
||||
return $this->base_url . ltrim(Utils::replaceFirstOccurrence(GRAV_WEBROOT, '', $asset), '/');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ class Cache extends Getters
|
||||
*/
|
||||
public function init(Grav $grav)
|
||||
{
|
||||
/** @var Config $config */
|
||||
$this->config = $grav['config'];
|
||||
$this->now = time();
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@ class Setup extends Data
|
||||
public function __construct($container)
|
||||
{
|
||||
// Configure main streams.
|
||||
$abs = str_starts_with(GRAV_SYSTEM_PATH, '/');
|
||||
$this->streams['system']['prefixes'][''] = $abs ? ['system', GRAV_SYSTEM_PATH] : ['system'];
|
||||
$this->streams['user']['prefixes'][''] = [GRAV_USER_PATH];
|
||||
$this->streams['cache']['prefixes'][''] = [GRAV_CACHE_PATH];
|
||||
$this->streams['log']['prefixes'][''] = [GRAV_LOG_PATH];
|
||||
@@ -197,16 +199,16 @@ class Setup extends Data
|
||||
if (null !== $setupFile) {
|
||||
// Make sure that the custom setup file exists. Terminates the script if not.
|
||||
if (!str_starts_with($setupFile, '/')) {
|
||||
$setupFile = GRAV_ROOT . '/' . $setupFile;
|
||||
$setupFile = GRAV_WEBROOT . '/' . $setupFile;
|
||||
}
|
||||
if (!is_file($setupFile)) {
|
||||
echo 'GRAV_SETUP_PATH is defined but does not point to existing setup file.';
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$setupFile = GRAV_ROOT . '/setup.php';
|
||||
$setupFile = GRAV_WEBROOT . '/setup.php';
|
||||
if (!is_file($setupFile)) {
|
||||
$setupFile = GRAV_ROOT . '/' . GRAV_USER_PATH . '/setup.php';
|
||||
$setupFile = GRAV_WEBROOT . '/' . GRAV_USER_PATH . '/setup.php';
|
||||
}
|
||||
if (!is_file($setupFile)) {
|
||||
$setupFile = null;
|
||||
@@ -234,7 +236,7 @@ class Setup extends Data
|
||||
$envPath .= '/';
|
||||
} else {
|
||||
// Use default location. Start with Grav 1.7 default.
|
||||
$envPath = GRAV_ROOT. '/' . GRAV_USER_PATH . '/env';
|
||||
$envPath = GRAV_WEBROOT. '/' . GRAV_USER_PATH . '/env';
|
||||
if (is_dir($envPath)) {
|
||||
$envPath = 'user://env/';
|
||||
} else {
|
||||
@@ -257,7 +259,7 @@ class Setup extends Data
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$locator = new UniformResourceLocator(GRAV_ROOT);
|
||||
$locator = new UniformResourceLocator(GRAV_WEBROOT);
|
||||
$files = [];
|
||||
|
||||
$guard = 5;
|
||||
|
||||
@@ -524,8 +524,12 @@ class Blueprint extends BlueprintForm
|
||||
* @param string $op
|
||||
* @return bool
|
||||
*/
|
||||
protected function resolveActions(UserInterface $user, array $actions, string $op = 'and')
|
||||
protected function resolveActions(?UserInterface $user, array $actions, string $op = 'and')
|
||||
{
|
||||
if (null === $user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$c = $i = count($actions);
|
||||
foreach ($actions as $key => $action) {
|
||||
if (!is_int($key) && is_array($actions)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ abstract class Archiver
|
||||
{
|
||||
// Set infinite PHP execution time if possible.
|
||||
if (Utils::functionExists('set_time_limit')) {
|
||||
set_time_limit(0);
|
||||
@set_time_limit(0);
|
||||
}
|
||||
|
||||
$this->options = $options + $this->options;
|
||||
|
||||
@@ -371,6 +371,10 @@ abstract class Folder
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($target, $source) === 0) {
|
||||
throw new RuntimeException('Cannot move folder to itself');
|
||||
}
|
||||
|
||||
if (file_exists($target)) {
|
||||
// Rename fails if target folder exists.
|
||||
throw new RuntimeException('Cannot move files to existing folder/file.');
|
||||
@@ -383,11 +387,7 @@ abstract class Folder
|
||||
@rename($source, $target);
|
||||
|
||||
// Rename function can fail while still succeeding, so let's check if the folder exists.
|
||||
if (!file_exists($target) || !is_dir($target)) {
|
||||
// In some rare cases rename() creates file, not a folder. Get rid of it.
|
||||
if (file_exists($target)) {
|
||||
@unlink($target);
|
||||
}
|
||||
if (is_dir($source)) {
|
||||
// Rename doesn't support moving folders across filesystems. Use copy instead.
|
||||
self::copy($source, $target);
|
||||
self::delete($source);
|
||||
|
||||
@@ -18,9 +18,8 @@ use Grav\Common\Flex\Traits\FlexGravTrait;
|
||||
* Class FlexCollection
|
||||
*
|
||||
* @package Grav\Common\Flex
|
||||
* @template TKey
|
||||
* @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
|
||||
* @extends \Grav\Framework\Flex\FlexCollection<TKey,T>
|
||||
* @extends \Grav\Framework\Flex\FlexCollection<T>
|
||||
*/
|
||||
abstract class FlexCollection extends \Grav\Framework\Flex\FlexCollection
|
||||
{
|
||||
|
||||
@@ -18,10 +18,9 @@ use Grav\Common\Flex\Traits\FlexIndexTrait;
|
||||
* Class FlexIndex
|
||||
*
|
||||
* @package Grav\Common\Flex
|
||||
* @template TKey
|
||||
* @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
|
||||
* @template C of \Grav\Framework\Flex\Interfaces\FlexCollectionInterface
|
||||
* @extends \Grav\Framework\Flex\FlexIndex<TKey,T,C>
|
||||
* @extends \Grav\Framework\Flex\FlexIndex<T,C>
|
||||
*/
|
||||
abstract class FlexIndex extends \Grav\Framework\Flex\FlexIndex
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexCollection;
|
||||
* Class GenericCollection
|
||||
* @package Grav\Common\Flex\Generic
|
||||
*
|
||||
* @extends FlexCollection<string,GenericObject>
|
||||
* @extends FlexCollection<GenericObject>
|
||||
*/
|
||||
class GenericCollection extends FlexCollection
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexIndex;
|
||||
* Class GenericIndex
|
||||
* @package Grav\Common\Flex\Generic
|
||||
*
|
||||
* @extends FlexIndex<string,GenericObject,GenericCollection>
|
||||
* @extends FlexIndex<GenericObject,GenericCollection>
|
||||
*/
|
||||
class GenericIndex extends FlexIndex
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ use function is_string;
|
||||
* Class GravPageCollection
|
||||
* @package Grav\Plugin\FlexObjects\Types\GravPages
|
||||
*
|
||||
* @extends FlexPageCollection<string,PageObject>
|
||||
* @extends FlexPageCollection<PageObject>
|
||||
*
|
||||
* Incompatibilities with Grav\Common\Page\Collection:
|
||||
* $page = $collection->key() will not work at all
|
||||
|
||||
@@ -38,7 +38,7 @@ use function is_string;
|
||||
* Class GravPageObject
|
||||
* @package Grav\Plugin\FlexObjects\Types\GravPages
|
||||
*
|
||||
* @extends FlexPageIndex<string,PageObject,PageCollection>
|
||||
* @extends FlexPageIndex<PageObject,PageCollection>
|
||||
*
|
||||
* @method PageIndex withModules(bool $bool = true)
|
||||
* @method PageIndex withPages(bool $bool = true)
|
||||
|
||||
@@ -204,10 +204,7 @@ class PageObject extends FlexPageObject
|
||||
}
|
||||
|
||||
// Make sure page isn't being moved under itself.
|
||||
$key = $this->getKey();
|
||||
if ($key === $parentKey || strpos($parentKey, $key . '/') === 0) {
|
||||
throw new RuntimeException(sprintf('Page /%s cannot be moved to %s', $key, $parentRoute));
|
||||
}
|
||||
$key = $this->getStorageKey();
|
||||
|
||||
/** @var PageObject|null $parent */
|
||||
$parent = $parentKey !== false ? $this->getFlexDirectory()->getObject($parentKey, 'storage_key') : null;
|
||||
@@ -301,6 +298,22 @@ class PageObject extends FlexPageObject
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageObject
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
// Backwards compatibility with older plugins.
|
||||
$fireEvents = $this->isAdminSite() && $this->getFlexDirectory()->getConfig('object.compat.events', true);
|
||||
if ($fireEvents) {
|
||||
$this->getContainer()->fireEvent('onAdminAfterDelete', new Event(['object' => $this]));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare move page to new location. Moves also everything that's under the current page.
|
||||
*
|
||||
|
||||
@@ -373,7 +373,7 @@ class PageStorage extends FolderStorage
|
||||
|
||||
try {
|
||||
if ($key === '' && empty($row['root'])) {
|
||||
throw new RuntimeException('No storage key given');
|
||||
throw new RuntimeException('Page has no path');
|
||||
}
|
||||
|
||||
$grav = Grav::instance();
|
||||
@@ -394,9 +394,17 @@ class PageStorage extends FolderStorage
|
||||
if ($oldFolder !== $newFolder && file_exists($oldFolder)) {
|
||||
$isCopy = $row['__META']['copy'] ?? false;
|
||||
if ($isCopy) {
|
||||
if (strpos($newFolder, $oldFolder . '/') === 0) {
|
||||
throw new RuntimeException(sprintf('Page /%s cannot be copied to itself', $oldKey));
|
||||
}
|
||||
|
||||
$this->copyRow($oldKey, $newKey);
|
||||
$debugger->addMessage("Page copied: {$oldFolder} => {$newFolder}", 'debug');
|
||||
} else {
|
||||
if (strpos($newFolder, $oldFolder . '/') === 0) {
|
||||
throw new RuntimeException(sprintf('Page /%s cannot be moved to itself', $oldKey));
|
||||
}
|
||||
|
||||
$this->renameRow($oldKey, $newKey);
|
||||
$debugger->addMessage("Page moved: {$oldFolder} => {$newFolder}", 'debug');
|
||||
}
|
||||
@@ -534,7 +542,7 @@ class PageStorage extends FolderStorage
|
||||
$markdown = [];
|
||||
$children = [];
|
||||
|
||||
if (is_string($path) && file_exists($path)) {
|
||||
if (is_string($path) && is_dir($path)) {
|
||||
$modified = filemtime($path);
|
||||
$iterator = new FilesystemIterator($path, $this->flags);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexCollection;
|
||||
* Class UserGroupCollection
|
||||
* @package Grav\Common\Flex\Types\UserGroups
|
||||
*
|
||||
* @extends FlexCollection<string,UserGroupObject>
|
||||
* @extends FlexCollection<UserGroupObject>
|
||||
*/
|
||||
class UserGroupCollection extends FlexCollection
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexIndex;
|
||||
* Class GroupIndex
|
||||
* @package Grav\Common\User\FlexUser
|
||||
*
|
||||
* @extends FlexIndex<string,UserGroupObject,UserGroupCollection>
|
||||
* @extends FlexIndex<UserGroupObject,UserGroupCollection>
|
||||
*/
|
||||
class UserGroupIndex extends FlexIndex
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ use function is_string;
|
||||
* Class UserCollection
|
||||
* @package Grav\Common\Flex\Types\Users
|
||||
*
|
||||
* @extends FlexCollection<string,UserObject>
|
||||
* @extends FlexCollection<UserObject>
|
||||
*/
|
||||
class UserCollection extends FlexCollection implements UserCollectionInterface
|
||||
{
|
||||
|
||||
@@ -15,20 +15,20 @@ use Grav\Common\Debugger;
|
||||
use Grav\Common\File\CompiledYamlFile;
|
||||
use Grav\Common\Flex\FlexIndex;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\User\Interfaces\UserCollectionInterface;
|
||||
use Grav\Common\User\Interfaces\UserInterface;
|
||||
use Grav\Framework\Flex\Interfaces\FlexStorageInterface;
|
||||
use Monolog\Logger;
|
||||
use function count;
|
||||
use function is_string;
|
||||
use function method_exists;
|
||||
|
||||
/**
|
||||
* Class UserIndex
|
||||
* @package Grav\Common\Flex\Types\Users
|
||||
*
|
||||
* @extends FlexIndex<string,UserObject,UserCollection>
|
||||
* @extends FlexIndex<UserObject,UserCollection>
|
||||
*/
|
||||
class UserIndex extends FlexIndex
|
||||
class UserIndex extends FlexIndex implements UserCollectionInterface
|
||||
{
|
||||
public const VERSION = parent::VERSION . '.1';
|
||||
|
||||
@@ -106,6 +106,24 @@ class UserIndex extends FlexIndex
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user account.
|
||||
*
|
||||
* @param string $username
|
||||
* @return bool True if user account was found and was deleted.
|
||||
*/
|
||||
public function delete($username): bool
|
||||
{
|
||||
$user = $this->load($username);
|
||||
|
||||
$exists = $user->exists();
|
||||
if ($exists) {
|
||||
$user->delete();
|
||||
}
|
||||
|
||||
return $exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a user by username, email, etc
|
||||
*
|
||||
|
||||
@@ -538,13 +538,18 @@ class UserObject extends FlexObject implements UserInterface, Countable
|
||||
}
|
||||
}
|
||||
|
||||
$password = $this->getProperty('password');
|
||||
if (null !== $password) {
|
||||
$this->unsetProperty('password');
|
||||
$this->unsetProperty('password1');
|
||||
$this->unsetProperty('password2');
|
||||
$password = $this->getProperty('password') ?? $this->getProperty('password1');
|
||||
if (null !== $password && '' !== $password) {
|
||||
$password2 = $this->getProperty('password2');
|
||||
if (!\is_string($password) || ($password2 && $password !== $password2)) {
|
||||
throw new \RuntimeException('Passwords did not match.');
|
||||
}
|
||||
|
||||
$this->setProperty('hashed_password', Authentication::create($password));
|
||||
}
|
||||
$this->unsetProperty('password');
|
||||
$this->unsetProperty('password1');
|
||||
$this->unsetProperty('password2');
|
||||
|
||||
// Backwards compatibility with older plugins.
|
||||
$fireEvents = $this->isAdminSite() && $this->getFlexDirectory()->getConfig('object.compat.events', true);
|
||||
|
||||
@@ -63,7 +63,7 @@ class Licenses
|
||||
* Returns the license for a Premium package
|
||||
*
|
||||
* @param string|null $slug
|
||||
* @return array|string
|
||||
* @return string[]|string
|
||||
*/
|
||||
public static function get($slug = null)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ class Response
|
||||
// check if this function is available, if so use it to stop any timeouts
|
||||
try {
|
||||
if (Utils::functionExists('set_time_limit')) {
|
||||
set_time_limit(0);
|
||||
@set_time_limit(0);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
@@ -41,6 +41,16 @@ trait ImageMediaTrait
|
||||
/** @var bool */
|
||||
protected $debug_watermarked = false;
|
||||
|
||||
/** @var bool */
|
||||
protected $auto_sizes;
|
||||
|
||||
/** @var bool */
|
||||
protected $aspect_ratio;
|
||||
|
||||
/** @var integer */
|
||||
protected $retina_scale;
|
||||
|
||||
|
||||
/** @var array */
|
||||
public static $magic_actions = [
|
||||
'resize', 'forceResize', 'cropResize', 'crop', 'zoomCrop',
|
||||
@@ -358,11 +368,17 @@ trait ImageMediaTrait
|
||||
->setPrettyName($this->getImagePrettyName());
|
||||
|
||||
// Fix orientation if enabled
|
||||
if (Grav::instance()['config']->get('system.images.auto_fix_orientation', false) &&
|
||||
$config = Grav::instance()['config'];
|
||||
if ($config->get('system.images.auto_fix_orientation', false) &&
|
||||
extension_loaded('exif') && function_exists('exif_read_data')) {
|
||||
$this->image->fixOrientation();
|
||||
}
|
||||
|
||||
// Set CLS configuration
|
||||
$this->auto_sizes = $config->get('system.images.cls.auto_sizes', false);
|
||||
$this->aspect_ratio = $config->get('system.images.cls.aspect_ratio', false);
|
||||
$this->retina_scale = $config->get('system.images.cls.retina_scale', 1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
use ImageMediaTrait;
|
||||
use ImageLoadingTrait;
|
||||
|
||||
/**
|
||||
* @var mixed|string
|
||||
*/
|
||||
private $saved_image_path;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
@@ -121,6 +126,12 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
|
||||
$this->debug_watermarked = false;
|
||||
|
||||
$config = $this->getGrav()['config'];
|
||||
// Set CLS configuration
|
||||
$this->auto_sizes = $config->get('system.images.cls.auto_sizes', false);
|
||||
$this->aspect_ratio = $config->get('system.images.cls.aspect_ratio', false);
|
||||
$this->retina_scale = $config->get('system.images.cls.retina_scale', 1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -170,7 +181,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $grav['locator'];
|
||||
$image_path = (string)($locator->findResource('cache://images', true) ?: $locator->findResource('cache://images', true, true));
|
||||
$saved_image_path = $this->saveImage();
|
||||
$saved_image_path = $this->saved_image_path = $this->saveImage();
|
||||
|
||||
$output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $saved_image_path) ?: $saved_image_path;
|
||||
|
||||
@@ -232,6 +243,23 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
$attributes['sizes'] = $this->sizes();
|
||||
}
|
||||
|
||||
if ($this->saved_image_path && $this->auto_sizes) {
|
||||
if (!array_key_exists('height', $this->attributes) && !array_key_exists('width', $this->attributes)) {
|
||||
$info = getimagesize($this->saved_image_path);
|
||||
$width = intval($info[0]);
|
||||
$height = intval($info[1]);
|
||||
|
||||
$scaling_factor = $this->retina_scale > 0 ? $this->retina_scale : 1;
|
||||
$attributes['width'] = intval($width / $scaling_factor);
|
||||
$attributes['height'] = intval($height / $scaling_factor);
|
||||
|
||||
if ($this->aspect_ratio) {
|
||||
$style = ($attributes['style'] ?? ' ') . "--aspect-ratio: $width/$height;";
|
||||
$attributes['style'] = trim($style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ['name' => 'img', 'attributes' => $attributes];
|
||||
}
|
||||
|
||||
@@ -274,6 +302,29 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
return parent::lightbox($width, $height, $reset);
|
||||
}
|
||||
|
||||
public function autoSizes($enabled = 'true')
|
||||
{
|
||||
$enabled = $enabled === 'true' ?: false;
|
||||
$this->auto_sizes = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function aspectRatio($enabled = 'true')
|
||||
{
|
||||
$enabled = $enabled === 'true' ?: false;
|
||||
$this->aspect_ratio = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function retinaScale($scale = 1)
|
||||
{
|
||||
$this->retina_scale = intval($scale);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle this commonly used variant
|
||||
*
|
||||
|
||||
@@ -61,7 +61,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (null === $this->systemBlueprints) {
|
||||
if (empty($this->systemBlueprints)) {
|
||||
// Register all blueprints from the blueprints stream.
|
||||
$this->systemBlueprints = $this->findBlueprints('blueprints://pages');
|
||||
foreach ($this->systemBlueprints as $type => $blueprint) {
|
||||
|
||||
@@ -178,7 +178,7 @@ class InitializeProcessor extends ProcessorBase
|
||||
$grav['plugins']->setup();
|
||||
|
||||
if (defined('GRAV_SCHEMA') && $config->get('versions') === null) {
|
||||
$filename = GRAV_ROOT . '/user/config/versions.yaml';
|
||||
$filename = USER_DIR . 'config/versions.yaml';
|
||||
if (!is_file($filename)) {
|
||||
$versions = [
|
||||
'core' => [
|
||||
|
||||
@@ -30,7 +30,7 @@ class StreamsServiceProvider implements ServiceProviderInterface
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container['locator'] = function (Container $container) {
|
||||
$locator = new UniformResourceLocator(GRAV_ROOT);
|
||||
$locator = new UniformResourceLocator(GRAV_WEBROOT);
|
||||
|
||||
/** @var Setup $setup */
|
||||
$setup = $container['setup'];
|
||||
|
||||
@@ -128,12 +128,12 @@ class Session extends \Grav\Framework\Session\Session
|
||||
/** @var Uri $uri */
|
||||
$uri = $grav['uri'];
|
||||
/** @var Forms|null $form */
|
||||
$form = $grav['forms']->getActiveForm();
|
||||
$form = $grav['forms']->getActiveForm(); // @phpstan-ignore-line
|
||||
|
||||
$sessionField = base64_encode($uri->url);
|
||||
|
||||
/** @var FormFlash|null $flash */
|
||||
$flash = $form ? $form->getFlash() : null;
|
||||
$flash = $form ? $form->getFlash() : null; // @phpstan-ignore-line
|
||||
$object = $flash && method_exists($flash, 'getLegacyFiles') ? [$sessionField => $flash->getLegacyFiles()] : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,8 +205,8 @@ class Uri
|
||||
// set active language
|
||||
$uri = $language->setActiveFromUri($uri);
|
||||
|
||||
// split the URL and params
|
||||
$bits = parse_url($uri);
|
||||
// split the URL and params (and make sure that the path isn't seen as domain)
|
||||
$bits = parse_url('http://domain.com' . $uri);
|
||||
|
||||
//process fragment
|
||||
if (isset($bits['fragment'])) {
|
||||
|
||||
@@ -131,11 +131,18 @@ class User extends Data implements UserInterface
|
||||
}
|
||||
|
||||
// if plain text password, hash it and remove plain text
|
||||
$password = $this->get('password');
|
||||
if ($password) {
|
||||
$password = $this->get('password') ?? $this->get('password1');
|
||||
if (null !== $password && '' !== $password) {
|
||||
$password2 = $this->get('password2');
|
||||
if (!\is_string($password) || ($password2 && $password !== $password2)) {
|
||||
throw new \RuntimeException('Passwords did not match.');
|
||||
}
|
||||
|
||||
$this->set('hashed_password', Authentication::create($password));
|
||||
$this->undef('password');
|
||||
}
|
||||
$this->undef('password');
|
||||
$this->undef('password1');
|
||||
$this->undef('password2');
|
||||
|
||||
$data = $this->items;
|
||||
if ($username === $data['username']) {
|
||||
|
||||
@@ -37,10 +37,9 @@ use function is_scalar;
|
||||
/**
|
||||
* Class FlexCollection
|
||||
* @package Grav\Framework\Flex
|
||||
* @template TKey
|
||||
* @template T of FlexObjectInterface
|
||||
* @extends ObjectCollection<TKey,T>
|
||||
* @implements FlexCollectionInterface<TKey,T>
|
||||
* @extends ObjectCollection<string,T>
|
||||
* @implements FlexCollectionInterface<T>
|
||||
*/
|
||||
class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
{
|
||||
@@ -460,7 +459,6 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
/**
|
||||
* @param string $key
|
||||
* @return array
|
||||
* @phpstan-param TKey $key
|
||||
*/
|
||||
public function getMetaData(string $key): array
|
||||
{
|
||||
@@ -491,7 +489,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
* @param string|null $scope
|
||||
* @param UserInterface|null $user
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function isAuthorized(string $action, string $scope = null, UserInterface $user = null)
|
||||
{
|
||||
@@ -559,7 +557,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
* @param array $elements Elements.
|
||||
* @param string|null $keyField
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function createFrom(array $elements, $keyField = null)
|
||||
|
||||
@@ -46,7 +46,6 @@ use function is_callable;
|
||||
* Class FlexDirectory
|
||||
* @package Grav\Framework\Flex
|
||||
* @template T
|
||||
* @template TKey
|
||||
*/
|
||||
class FlexDirectory implements FlexDirectoryInterface, FlexAuthorizeInterface
|
||||
{
|
||||
@@ -309,7 +308,7 @@ class FlexDirectory implements FlexDirectoryInterface, FlexAuthorizeInterface
|
||||
* @param array|null $keys Array of keys.
|
||||
* @param string|null $keyField Field to be used as the key.
|
||||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<TKey,T>
|
||||
* @phpstan-return FlexCollectionInterface<T>
|
||||
*/
|
||||
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface
|
||||
{
|
||||
|
||||
@@ -33,11 +33,10 @@ use function in_array;
|
||||
/**
|
||||
* Class FlexIndex
|
||||
* @package Grav\Framework\Flex
|
||||
* @template TKey
|
||||
* @template T of FlexObjectInterface
|
||||
* @template C of FlexCollectionInterface
|
||||
* @extends ObjectIndex<TKey,T>
|
||||
* @implements FlexIndexInterface<TKey,T>
|
||||
* @extends ObjectIndex<string,T>
|
||||
* @implements FlexIndexInterface<T>
|
||||
* @mixin C
|
||||
*/
|
||||
class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexIndexInterface
|
||||
@@ -54,7 +53,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
/**
|
||||
* @param FlexDirectory $directory
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T,C>
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public static function createFromStorage(FlexDirectory $directory)
|
||||
{
|
||||
@@ -343,7 +342,6 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
/**
|
||||
* @param string $key
|
||||
* @return array
|
||||
* @phpstan-param TKey $key
|
||||
*/
|
||||
public function getMetaData($key): array
|
||||
{
|
||||
@@ -370,7 +368,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
/**
|
||||
* @param array $orderings
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T,C>
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function orderBy(array $orderings)
|
||||
{
|
||||
@@ -538,7 +536,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
* @param array $entries
|
||||
* @param string|null $keyField
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T,C>
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
protected function createFrom(array $entries, string $keyField = null)
|
||||
{
|
||||
|
||||
@@ -22,9 +22,8 @@ use InvalidArgumentException;
|
||||
*
|
||||
* @used-by \Grav\Framework\Flex\FlexCollection
|
||||
* @since 1.6
|
||||
* @template TKey
|
||||
* @template T
|
||||
* @extends ObjectCollectionInterface<TKey,T>
|
||||
* @extends ObjectCollectionInterface<string,T>
|
||||
*/
|
||||
interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionInterface, NestedObjectInterface
|
||||
{
|
||||
@@ -58,7 +57,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
* @param string|string[]|null $properties Properties to search for, defaults to configured properties.
|
||||
* @param array|null $options Search options, defaults to configured options.
|
||||
* @return FlexCollectionInterface Returns a Flex Collection with only matching objects.
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null);
|
||||
@@ -69,7 +68,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
* @param array $orderings Pair of [property => 'ASC'|'DESC', ...].
|
||||
*
|
||||
* @return FlexCollectionInterface Returns a sorted version from the collection.
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function sort(array $orderings);
|
||||
|
||||
@@ -78,7 +77,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
*
|
||||
* @param array $filters
|
||||
* @return FlexCollectionInterface
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function filterBy(array $filters);
|
||||
|
||||
@@ -114,7 +113,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
*
|
||||
* @param string|null $keyField Switch key field of the collection.
|
||||
* @return FlexCollectionInterface Returns a new Flex Collection with new key field.
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function withKeyField(string $keyField = null);
|
||||
@@ -123,7 +122,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
* Get Flex Index from the Flex Collection.
|
||||
*
|
||||
* @return FlexIndexInterface Returns a Flex Index from the current collection.
|
||||
* @phpstan-return FlexIndexInterface<TKey,T>
|
||||
* @phpstan-return FlexIndexInterface<T>
|
||||
*/
|
||||
public function getIndex();
|
||||
|
||||
@@ -131,7 +130,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
* Load all the objects into memory,
|
||||
*
|
||||
* @return FlexCollectionInterface
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function getCollection();
|
||||
|
||||
@@ -140,7 +139,6 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @return array
|
||||
* @phpstan-param TKey $key
|
||||
*/
|
||||
public function getMetaData(string $key): array;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@ use Grav\Framework\Flex\FlexDirectory;
|
||||
*
|
||||
* @used-by \Grav\Framework\Flex\FlexIndex
|
||||
* @since 1.6
|
||||
* @template TKey
|
||||
* @template T
|
||||
* @extends FlexCollectionInterface<TKey,T>
|
||||
* @extends FlexCollectionInterface<T>
|
||||
*/
|
||||
interface FlexIndexInterface extends FlexCollectionInterface
|
||||
{
|
||||
|
||||
@@ -20,9 +20,8 @@ use function is_int;
|
||||
/**
|
||||
* Class FlexPageCollection
|
||||
* @package Grav\Plugin\FlexObjects\Types\FlexPages
|
||||
* @template TKey
|
||||
* @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
|
||||
* @extends FlexCollection<TKey,T>
|
||||
* @extends FlexCollection<T>
|
||||
*/
|
||||
class FlexPageCollection extends FlexCollection
|
||||
{
|
||||
@@ -53,7 +52,7 @@ class FlexPageCollection extends FlexCollection
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withPublished(bool $bool = true)
|
||||
{
|
||||
@@ -65,7 +64,7 @@ class FlexPageCollection extends FlexCollection
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withVisible(bool $bool = true)
|
||||
{
|
||||
@@ -77,7 +76,7 @@ class FlexPageCollection extends FlexCollection
|
||||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withRoutable(bool $bool = true)
|
||||
{
|
||||
|
||||
@@ -22,10 +22,9 @@ use Grav\Framework\Flex\FlexIndex;
|
||||
* @method FlexPageIndex withPublished(bool $bool = true)
|
||||
* @method FlexPageIndex withVisible(bool $bool = true)
|
||||
*
|
||||
* @template TKey
|
||||
* @template T of FlexPageObject
|
||||
* @template C of FlexPageCollection
|
||||
* @extends FlexIndex<TKey,T,C>
|
||||
* @extends FlexIndex<T,C>
|
||||
*/
|
||||
class FlexPageIndex extends FlexIndex
|
||||
{
|
||||
|
||||
@@ -205,10 +205,10 @@ trait FlexMediaTrait
|
||||
$filename = $info['path'] ?? $info['name'];
|
||||
}
|
||||
|
||||
/** @var Medium|null $thumbFile */
|
||||
/** @var Medium|null $imageFile */
|
||||
$imageFile = $media[$filename];
|
||||
|
||||
/** @var Medium|null $thumbFile */
|
||||
/** @var Medium|null $originalFile */
|
||||
$originalFile = $originalMedia ? $originalMedia[$filename] : null;
|
||||
|
||||
$url = $imageFile ? $imageFile->url() : null;
|
||||
@@ -384,7 +384,7 @@ trait FlexMediaTrait
|
||||
$updated = true;
|
||||
if ($medium) {
|
||||
$media->add($filename, $medium);
|
||||
} else {
|
||||
} elseif (is_callable([$media, 'hide'])) {
|
||||
$media->hide($filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ ERR;
|
||||
|
||||
$this->location = dirname($location, 4);
|
||||
|
||||
$versions = Versions::instance(GRAV_ROOT . '/user/config/versions.yaml');
|
||||
$versions = Versions::instance(USER_DIR . 'config/versions.yaml');
|
||||
$this->updater = new VersionUpdater('core/grav', __DIR__ . '/updates', $this->getVersion(), $versions);
|
||||
|
||||
$this->updater->preflight();
|
||||
@@ -280,7 +280,7 @@ ERR;
|
||||
{
|
||||
// Finalize can be run without installing Grav first.
|
||||
if (!$this->updater) {
|
||||
$versions = Versions::instance(GRAV_ROOT . '/user/config/versions.yaml');
|
||||
$versions = Versions::instance(USER_DIR . 'config/versions.yaml');
|
||||
$this->updater = new VersionUpdater('core/grav', __DIR__ . '/updates', GRAV_VERSION, $versions);
|
||||
$this->updater->install();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ final class Versions
|
||||
*/
|
||||
public static function instance(string $filename = null): self
|
||||
{
|
||||
$filename = $filename ?? GRAV_ROOT . '/user/config/versions.yaml';
|
||||
$filename = $filename ?? USER_DIR . 'config/versions.yaml';
|
||||
|
||||
if (!isset(self::$instance[$filename])) {
|
||||
self::$instance[$filename] = new self($filename);
|
||||
|
||||
Reference in New Issue
Block a user