4 |
5 | **READ ONLY REPOSITORY - PULL REQUESTS MUST BE SUBMITED TO [LUYADEV/LUYA](https://github.com/luyadev/luya)**
6 |
7 | The LUYA core extends the [Yii 2 Framework](https://github.com/yiisoft/yii2) by helpers and a structured way to run and build any web application you can think of.
8 |
9 | [](https://travis-ci.org/luyadev/luya)
10 | [](https://codeclimate.com/github/luyadev/luya/test_coverage)
11 | [](https://codeclimate.com/github/luyadev/luya/maintainability)
12 | [](https://packagist.org/packages/luyadev/luya-core)
13 | [](https://www.yiiframework.com/)
14 |
15 | ## About the LUYA core
16 |
17 | There is a clear vision of the structure for modern web applications, in particluar:
18 |
19 | + How to use configuration files and keep them small
20 | + Arrangement and structure of directories
21 | + Components wich are already set by the core
22 | + Bulletproof DRY concept for secure and fast development
23 |
24 | In other words it means you can also use LUYA to build an application without administration or cms but it still allows you to maintain the same code base over different projects, e.g. with just an MVC provided by Yii via the LUYA core or if you just need an admin UI where you can manage data of your application or as well if you also need a cms to manage the content.
25 |
26 | [Read more in the Guide](https://luya.io/guide/concept-core)
27 |
--------------------------------------------------------------------------------
/core/Yii.php:
--------------------------------------------------------------------------------
1 |
13 | * @since 1.0.0
14 | */
15 | interface CoreModuleInterface
16 | {
17 | }
18 |
--------------------------------------------------------------------------------
/core/base/DynamicModel.php:
--------------------------------------------------------------------------------
1 | setAttributeHints(['query' => 'Enter a search term in order to find articles.']);
15 | * $model->addRule(['query'], 'string');
16 | * $model->addRule(['query'], 'required');
17 | * ```
18 | *
19 | * @author Basil Suter
20 | * @since 1.0.0
21 | */
22 | class DynamicModel extends \yii\base\DynamicModel
23 | {
24 | /**
25 | * @var array An array with key value pairing where key is the attribute and value the label.
26 | * @since 1.0.15
27 | */
28 | public $_attributeHints = [];
29 |
30 | /**
31 | * Sets the attribute hints in a massive way.
32 | *
33 | * @param array $hints Array of attribute hints
34 | * @return $this
35 | * @since 2.1.0
36 | */
37 | public function setAttributeHints(array $hints)
38 | {
39 | $this->_attributeHints = $hints;
40 | return $this;
41 | }
42 |
43 | /**
44 | * Get all hints for backwards compatibility.
45 | *
46 | * @return array
47 | * @since 2.1.0
48 | */
49 | public function getAttributeHints()
50 | {
51 | return $this->_attributeHints;
52 | }
53 |
54 | /**
55 | * {@inheritDoc}
56 | */
57 | public function attributeHints()
58 | {
59 | $hints = [];
60 | foreach ($this->attributeHints as $key => $value) {
61 | $hints[$key] = Yii::t('app', $value);
62 | }
63 |
64 | return $hints;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/core/base/PackageInstaller.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.0
15 | */
16 | class PackageInstaller extends BaseObject
17 | {
18 | private $_timestamp;
19 |
20 | /**
21 | * Setter method for timestamp.
22 | *
23 | * @param integer $timestamp
24 | */
25 | public function setTimestamp($timestamp)
26 | {
27 | $this->_timestamp = $timestamp;
28 | }
29 |
30 | /**
31 | * Getter method for timestamp.
32 | *
33 | * @return integer
34 | */
35 | public function getTimestamp()
36 | {
37 | return $this->_timestamp;
38 | }
39 |
40 | private $_configs = [];
41 |
42 | /**
43 | * Setter method for configurations (PackageConfig).
44 | *
45 | * @param array $configs
46 | */
47 | public function setConfigs(array $configs)
48 | {
49 | $objects = [];
50 | foreach ($configs as $key => $config) {
51 | // create package object
52 | $packageConfig = new PackageConfig();
53 | $packageConfig->setValues($config);
54 | // assign object
55 | $objects[$key] = $packageConfig;
56 | }
57 |
58 | $this->_configs = $objects;
59 | }
60 |
61 | /**
62 | * Getter method for Configs.
63 | *
64 | * @return PackageConfig[]
65 | */
66 | public function getConfigs()
67 | {
68 | return $this->_configs;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/core/base/Widget.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 1.0.0
17 | */
18 | class Widget extends \yii\base\Widget
19 | {
20 | /**
21 | * @var boolean Whether to find view files inside the `@app/views` folder or the original widget implementation.
22 | */
23 | public $useAppViewPath = false;
24 |
25 | /**
26 | * Find view paths in application folder.
27 | *
28 | * @inheritDoc
29 | *
30 | * @see \yii\base\Widget::getViewPath()
31 | * @return string
32 | */
33 | public function getViewPath()
34 | {
35 | if (!$this->useAppViewPath) {
36 | return parent::getViewPath();
37 | }
38 |
39 | // get reflection
40 | $class = new ReflectionClass($this);
41 | // get path with alias
42 | return '@app/views/widgets/' . Inflector::camel2id($class->getShortName());
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/core/behaviors/HtmlEncodeBehavior.php:
--------------------------------------------------------------------------------
1 | [
17 | * 'class' => 'luya\behaviors\HtmlEncodeBehavior',
18 | * 'attributes' => [
19 | * 'firstname', 'lastname', 'text',
20 | * ],
21 | * ],
22 | * ];
23 | * }
24 | * ```
25 | *
26 | * You can also use the {{luya\behaviors\HtmlEncodeBehavior::htmlEncode()}} function when behavior is
27 | * attached like a trait would.
28 | *
29 | * @author Basil Suter
30 | * @since 1.0.9
31 | */
32 | class HtmlEncodeBehavior extends Behavior
33 | {
34 | public $attributes = [];
35 |
36 | /**
37 | * @inheritdoc
38 | */
39 | public function events()
40 | {
41 | return [
42 | ActiveRecord::EVENT_AFTER_FIND => 'afterFind',
43 | ];
44 | }
45 |
46 | /**
47 | * Event will be triggered after find.
48 | *
49 | * @param \yii\base\Event $event The after find event.
50 | */
51 | public function afterFind($event)
52 | {
53 | foreach ($this->attributes as $attribute) {
54 | $this->owner->{$attribute} = $this->htmlEncode($this->owner->{$attribute});
55 | }
56 | }
57 |
58 | /**
59 | * Encodes the given value based on {{luya\helpers\Html::encode()}}.
60 | *
61 | * @param string $value The value which should be encoded.
62 | * @return string Returns the encoded value.
63 | */
64 | public function htmlEncode($value)
65 | {
66 | return Html::encode($value);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/core/behaviors/TimestampBehavior.php:
--------------------------------------------------------------------------------
1 | [
15 | * 'class' => \luya\behaviors\TimestampBehavior::class,
16 | * 'insert' => ['last_update'],
17 | * 'update' => ['last_update'],
18 | * ]
19 | * ```
20 | *
21 | * @author Basil Suter
22 | * @since 1.0.9
23 | */
24 | class TimestampBehavior extends Behavior
25 | {
26 | /**
27 | * @var array An array with all fields where the timestamp should be applied to on insert.
28 | */
29 | public $insert = [];
30 |
31 | /**
32 | * @var array An array with all fields where the timestamp should be applied to on update.
33 | */
34 | public $update = [];
35 |
36 | /**
37 | * Register event handlers before insert and update.
38 | *
39 | * @see \yii\base\Behavior::events()
40 | */
41 | public function events()
42 | {
43 | return [
44 | ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert',
45 | ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeUpdate',
46 | ];
47 | }
48 |
49 | /**
50 | * Insert the timestamp for all provided fields.
51 | *
52 | * @param \yii\base\Event $event Event object from Active Record.
53 | */
54 | public function beforeInsert($event)
55 | {
56 | foreach ($this->insert as $field) {
57 | $event->sender->$field = time();
58 | }
59 | }
60 |
61 | /**
62 | * Update the timestamp for all provided fields.
63 | *
64 | * @param \yii\base\Event $event Event object from Active Record.
65 | */
66 | public function beforeUpdate($event)
67 | {
68 | foreach ($this->update as $field) {
69 | $event->sender->$field = time();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/core/bin/luya:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | configFile = $configFile;
35 | $boot->setBaseYiiFile($vendor . '/yiisoft/yii2/Yii.php');
36 | $boot->applicationConsole();
37 |
--------------------------------------------------------------------------------
/core/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "luyadev/luya-core",
3 | "description": "LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.",
4 | "type": "luya-core",
5 | "keywords": [
6 | "luya",
7 | "core",
8 | "yii2",
9 | "yii",
10 | "cms",
11 | "admin"
12 | ],
13 | "license": "MIT",
14 | "homepage": "https://luya.io",
15 | "authors": [
16 | {
17 | "name": "Basil Suter",
18 | "email": "git@nadar.io",
19 | "homepage": "https://github.com/nadar"
20 | }
21 | ],
22 | "support": {
23 | "issues": "https://github.com/luyadev/luya/issues"
24 | },
25 | "require": {
26 | "luyadev/luya-composer": "^1.0",
27 | "luyadev/yii-helpers": "^1.0",
28 | "yiisoft/yii2": "~2.0.15",
29 | "curl/curl": "^2.0 || ^1.0",
30 | "phpmailer/phpmailer": "^6.0",
31 | "giggsey/libphonenumber-for-php": "^8.11"
32 | },
33 | "autoload": {
34 | "psr-4": {
35 | "luya\\": ""
36 | }
37 | },
38 | "config": {
39 | "fxp-asset": {
40 | "enabled": false
41 | },
42 | "allow-plugins": {
43 | "yiisoft/yii2-composer": true,
44 | "luyadev/luya-composer": true
45 | }
46 | },
47 | "repositories": [
48 | {
49 | "type": "composer",
50 | "url": "https://asset-packagist.org"
51 | }
52 | ],
53 | "bin": [
54 | "bin/luya"
55 | ]
56 | }
57 |
--------------------------------------------------------------------------------
/core/console/Bootstrap.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.0
15 | */
16 | class Bootstrap extends BaseBootstrap
17 | {
18 | /**
19 | * Add missing alias names @web and @webroot.
20 | *
21 | * @param object $app Luya CLI Application Object
22 | *
23 | * @see \luya\base\BaseBootstrap::beforeRun()
24 | */
25 | public function beforeRun($app)
26 | {
27 | Yii::setAlias('@web', $app->basePath);
28 | Yii::setAlias('@webroot', $app->webroot);
29 | }
30 |
31 | /**
32 | * The run method must be implemented by defintion.
33 | *
34 | * @see \luya\base\BaseBootstrap::run()
35 | */
36 | public function run($app)
37 | {
38 | foreach ($app->getApplicationModules() as $id => $module) {
39 | $folder = $module->basePath . DIRECTORY_SEPARATOR . 'commands';
40 | if (file_exists($folder) && is_dir($folder)) {
41 | foreach (FileHelper::findFiles($folder) as $file) {
42 | $module->controllerNamespace = $module->namespace . '\commands';
43 |
44 | $className = '\\'.$module->getNamespace().'\\commands\\' . pathinfo($file, PATHINFO_FILENAME);
45 |
46 | $command = str_replace('-controller', '', $module->id . '/' . Inflector::camel2id(pathinfo($file, PATHINFO_FILENAME)));
47 |
48 | Yii::$app->controllerMap[$command] = ['class' => $className];
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/core/console/ErrorHandler.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class ErrorHandler extends \yii\console\ErrorHandler
14 | {
15 | use ErrorHandlerTrait;
16 |
17 | /**
18 | * @var string This propertie has been added in order to make sure console commands config
19 | * does also work in console env.
20 | */
21 | public $errorAction;
22 | }
23 |
--------------------------------------------------------------------------------
/core/console/commands/views/module/adminmodule.php:
--------------------------------------------------------------------------------
1 |
6 |
7 | namespace = $ns ?>\admin;
8 |
9 | /**
10 | * = $name; ?> Admin Module.
11 | *
12 | * = $luyaText; ?>
13 | *
14 | * @author
15 | * @since 1.0.0
16 | */
17 | class Module extends \luya\admin\base\Module
18 | {
19 |
20 | }
--------------------------------------------------------------------------------
/core/console/commands/views/module/frontendmodule.php:
--------------------------------------------------------------------------------
1 |
6 |
7 | namespace = $ns ?>\frontend;
8 |
9 | /**
10 | * = $name; ?> Frontend Module.
11 | *
12 | * = $luyaText; ?>
13 | *
14 | * @author
15 | * @since 1.0.0
16 | */
17 | class Module extends \luya\base\Module
18 | {
19 |
20 | }
--------------------------------------------------------------------------------
/core/console/commands/views/module/readme.php:
--------------------------------------------------------------------------------
1 | # = $humanName; ?> Module
9 |
10 | = $luyaText; ?>
11 |
12 | ## Installation
13 |
14 | In order to add the modules to your project go into the modules section of your config:
15 |
16 | ```php
17 | return [
18 | 'modules' => [
19 | // ...
20 | '= $name; ?>frontend' => [
21 | 'class' => '= $ns; ?>\frontend\Module',
22 | 'useAppViewPath' => true, // When enabled the views will be looked up in the @app/views folder, otherwise the views shipped with the module will be used.
23 | ],
24 | '= $name; ?>admin' => '= $ns; ?>\admin\Module',
25 | // ...
26 | ],
27 | ];
28 | ```
29 |
--------------------------------------------------------------------------------
/core/console/interfaces/ImportControllerInterface.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.0
10 | */
11 | interface ImportControllerInterface
12 | {
13 | /**
14 | * Get all files from a directory.
15 | *
16 | * The directory must be in _scanFolders map of the {{luya\console\commands\ImporterController}}. An array will be returned with the keys:
17 | *
18 | * + file: The name of the file inside the provided folder (e.g. MyBlock.php)
19 | * + module: The name of the module where the file belongs to.
20 | * + ns: The namespace for the file including the filename itself.
21 | *
22 | * Usage example:
23 | *
24 | * ```php
25 | * $this->getDirectoryFiles('blocks');
26 | * ```
27 | *
28 | * If there are no files found getDirectoryFiles will return an empty array.
29 | *
30 | * @param string $folderName The folder name to find all files from.
31 | * @return array If no files found for the given folder an empty array will be returned, otherwise a list of all files inside the given folder.
32 | */
33 | public function getDirectoryFiles($folderName);
34 |
35 | /**
36 | * Add something to the log output.
37 | *
38 | * ```php
39 | * $this->addLog(get_called_class(), 'new block have been found and added to database');
40 | * ```
41 | *
42 | * @param string $section The section of where the log is executed.
43 | * @param string $value The message to log.
44 | */
45 | public function addLog($section, $value);
46 | }
47 |
--------------------------------------------------------------------------------
/core/exceptions/WhitelistedException.php:
--------------------------------------------------------------------------------
1 | Whitelisted Exception won't be transmitted to the LUYA error api.
11 | *
12 | * @author Basil Suter
13 | * @since 1.0.21
14 | */
15 | class WhitelistedException extends Exception
16 | {
17 | }
18 |
--------------------------------------------------------------------------------
/core/helpers/ArrayHelper.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class ArrayHelper extends HelpersArrayHelper
14 | {
15 | }
16 |
--------------------------------------------------------------------------------
/core/helpers/ExportHelper.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class ExportHelper extends HelpersExportHelper
14 | {
15 | }
16 |
--------------------------------------------------------------------------------
/core/helpers/FileHelper.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.0
11 | */
12 | class FileHelper extends HelpersFileHelper
13 | {
14 | }
15 |
--------------------------------------------------------------------------------
/core/helpers/Html.php:
--------------------------------------------------------------------------------
1 |
11 | */
12 | class Html extends HelpersHtml
13 | {
14 | }
15 |
--------------------------------------------------------------------------------
/core/helpers/ImportHelper.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class ImportHelper extends HelpersImportHelper
14 | {
15 | }
16 |
--------------------------------------------------------------------------------
/core/helpers/Inflector.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 1.0.0
16 | */
17 | class Inflector extends HelpersInflector
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/core/helpers/Json.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 1.0.3
16 | */
17 | class Json extends HelpersJson
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/core/helpers/RestHelper.php:
--------------------------------------------------------------------------------
1 |
12 | */
13 | class RestHelper extends HelpersRestHelper
14 | {
15 | }
16 |
--------------------------------------------------------------------------------
/core/helpers/StringHelper.php:
--------------------------------------------------------------------------------
1 |
20 | * @since 1.0.0
21 | */
22 | class StringHelper extends HelpersStringHelper
23 | {
24 | }
25 |
--------------------------------------------------------------------------------
/core/helpers/Url.php:
--------------------------------------------------------------------------------
1 |
24 | * @since 1.0.0
25 | */
26 | class Url extends HelpersUrl
27 | {
28 | }
29 |
--------------------------------------------------------------------------------
/core/helpers/XLSXWriter.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class ZipHelper extends HelpersZipHelper
14 | {
15 | }
16 |
--------------------------------------------------------------------------------
/core/lazyload/IntersectionObserverPolyfillAsset.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.6.0
12 | */
13 | class IntersectionObserverPolyfillAsset extends Asset
14 | {
15 | /**
16 | * @var string The path to the source files of the asset.
17 | */
18 | public $sourcePath = '@luya/resources/lazyload';
19 |
20 | /**
21 | * @var array An array with all javascript files for this asset located in the source path folder.
22 | */
23 | public $js = [
24 | YII_DEBUG ? 'intersectionObserver.polyfill.src.js' : 'intersectionOberserver.polyfill.js',
25 | ];
26 |
27 | /**
28 | * @var array An array with assets this asset depends on.
29 | */
30 | public $depends = [
31 | 'yii\web\JqueryAsset',
32 | ];
33 | }
34 |
--------------------------------------------------------------------------------
/core/lazyload/LazyLoadAsset.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class LazyLoadAsset extends Asset
14 | {
15 | /**
16 | * @var string The path to the source files of the asset.
17 | */
18 | public $sourcePath = '@luya/resources/lazyload';
19 |
20 | /**
21 | * @var array An array with all javascript files for this asset located in the source path folder.
22 | */
23 | public $js = [
24 | YII_DEBUG ? 'lazyload.src.js' : 'lazyload.js',
25 | ];
26 |
27 | /**
28 | * @var array An array with assets this asset depends on.
29 | */
30 | public $depends = [
31 | 'yii\web\JqueryAsset',
32 | ];
33 | }
34 |
--------------------------------------------------------------------------------
/core/messages/bg/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} трябва да има поне {length} знака.',
5 | '{attribute} must include at least one special character.' => '{attribute} трябва да съдържа поне един специален знак. ',
6 | '{attribute} must include at least one digit.' => '{attribute} трябва да съдържа поне едно число.',
7 | '{attribute} must include at least one letter.' => '{attribute} трябва да съдържа поне една буква.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute} трябва да съдържа поне една главна буква.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute} трябва да съдържа поне една малка буква.',
10 | '{attribute} must be a float or numeric value.' => '{attribute} трябва да е числова стойност.',
11 | 'Invalid phone number.' => 'Невалиден телефонен номер.',
12 | 'The phone number does not match the required type {name}.' => 'Телефонният номер не съответства на очаквания тип {name}.',
13 | 'Invalid phone number, ensure it starts with the correct country code.' => 'Невалиден телефонен номер; уверете се, че започва с правилния код на държавата.',
14 | ];
15 |
--------------------------------------------------------------------------------
/core/messages/de/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} muss mindestens über {length} Zeichen verfügen.',
5 | '{attribute} must include at least one special character.' => '{attribute} muss mindestens ein Spezial-Zeichen enthalten.',
6 | '{attribute} must include at least one digit.' => '{attribute} muss mindestens eine Zahl enthalten.',
7 | '{attribute} must include at least one letter.' => '{attribute} muss mindestens einen Buchstaben enthalten.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute} muss mindestens einen Grossbuchstaben enthalten.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute} muss mindestens einen Kleinbuchstaben enthalten.',
10 | '{attribute} must be a float or numeric value.' => '{attribute} muss ein Numerischer Wert sein.',
11 | 'Invalid phone number.' => 'Ungültige Telefonnummer.',
12 | 'The phone number does not match the required type {name}.' => 'Die Telefonnummer entspricht nicht dem erwarteten Typen {name}.',
13 | 'Invalid phone number, ensure it starts with the correct country code.' => 'Ungültige Telefonnummer; stellen Sie sicher, dass sie mit dem korrekten Ländercode beginnt.',
14 | ];
15 |
--------------------------------------------------------------------------------
/core/messages/fr/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} doit avoir une longueur minimale de {length} charactères.',
5 | '{attribute} must include at least one special character.' => '{attribute} doit comporter au moins un charactère spécial.',
6 | '{attribute} must include at least one digit.' => '{attribute} doit comporter au moins un chiffre.',
7 | '{attribute} must include at least one letter.' => '{attribute} doit comporter au moins une lettre.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute} doit comporter au moins une lettre majuscule.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute} doit comporter au moins une lettre minuscule.',
10 | '{attribute} must be a float or numeric value.' => '{attribute} doit être un nombre à virgule ou une valeur numérique.',
11 | 'Invalid phone number.' => 'Numéro de téléphone non valide.',
12 | 'The phone number does not match the required type {name}.' => 'Le numéro de téléphone ne correspond pas au type requis {name}.',
13 | 'Invalid phone number, ensure it starts with the correct country code.' => 'Numéro de téléphone non valide, assurez-vous qu\'il commence par le bon code de pays.',
14 | ];
15 |
--------------------------------------------------------------------------------
/core/messages/hu/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} legalább {length} karakter hosszúságú lehet.',
5 | '{attribute} must include at least one special character.' => '{attribute} tartalmaznia kell legalább egy speciális karaktert.',
6 | '{attribute} must include at least one digit.' => '{attribute} tartalmaznia kell legalább egy számjegyet.',
7 | '{attribute} must include at least one letter.' => '{attribute} legalább egy betűt tartalmaznia kell.',
8 | '{attribute} must include at least one uppercase letter.' => 'Az {attribute} tartalmaznia kell legalább egy nagybetűt.',
9 | '{attribute} must include at least one lowercase letter.' => 'Az {attribute} tartalmaznia kell legalább egy kisbetűt.',
10 | '{attribute} must be a float or numeric value.' => 'Az {attribute} lebegő vagy numerikus értéknek kell lennie.',
11 | 'Invalid phone number.' => 'Érvénytelen telefonszám.',
12 | 'The phone number does not match the required type {name}.' => 'A telefonszám nem egyezik a szükséges típussal {name}.',
13 | 'Invalid phone number, ensure it starts with the correct country code.' => 'Érvénytelen telefonszám, győződjön meg róla, hogy a megfelelő országkóddal kezdődik.',
14 | ];
15 |
--------------------------------------------------------------------------------
/core/messages/pl/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} musi mieć co najmniej {length} znaków.',
5 | '{attribute} must include at least one special character.' => '{attribute} musi zawierać przynajmniej jeden znak specjalny.',
6 | '{attribute} must include at least one digit.' => '{attribute} musi zawierać co najmniej jedną cyfrę.',
7 | '{attribute} must include at least one letter.' => '{attribute} musi zawierać co najmniej jedną literę.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute} musi zawierać co najmniej jedną wielką literę.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute} musi zawierać co najmniej jedną małą literę.',
10 | '{attribute} must be a float or numeric value.' => '{attribute} musi być wartością zmiennoprzecinkową lub liczbową.'
11 | ];
12 |
--------------------------------------------------------------------------------
/core/messages/pt/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} deve ter o mínimo de {length} caracteres.',
5 | '{attribute} must include at least one special character.' => '{attribute} deve incluir no mínimo um caracter especial.',
6 | '{attribute} must include at least one digit.' => '{attribute} deve incluir no mínimo um dígito.',
7 | '{attribute} must include at least one letter.' => '{attribute} deve incluir no mínimo uma letra.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute} deve incluir no mínimo uma letra maiúscula.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute} deve incluir no mínimo uma letra minúscula.',
10 | '{attribute} must be a float or numeric value.' => '{attribute} deve ser um valor númerico (com ou sem núneros após vírgula).',
11 | 'Invalid phone number.' => 'Número de telefone inválido',
12 | 'The phone number does not match the required type {name}.' => 'O número de telefone não corresponde com tipo {name} requerido.',
13 | 'Invalid phone number, ensure it starts with the correct country code.' => 'Número de telefone inválido, assegure-se que ele inicia com o código correto do país.',
14 | ];
15 |
--------------------------------------------------------------------------------
/core/messages/ro/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute} trebuie să aibă o lungime minimă de {length} caractere.',
5 | '{attribute} must include at least one special character.' => '{attribute} trebuie să includă cel puțin un caracter special.',
6 | '{attribute} must include at least one digit.' => '{attribute} trebuie să includă cel puțin o cifră.',
7 | '{attribute} must include at least one letter.' => '{attribute} trebuie să includă cel puțin o literă.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute} trebuie să includă cel puțin o literă mare.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute} trebuie să includă cel puțin o literă mică.',
10 | '{attribute} must be a float or numeric value.' => '{attribute} trebuie să fie o valoare numerică sau float.',
11 | 'Invalid phone number.' => 'Numar de telefon invalid.',
12 | 'The phone number does not match the required type {name}.' => 'Numărul de telefon nu se potrivește cu tipul necesar {name}.',
13 | 'Invalid phone number, ensure it starts with the correct country code.' => 'Număr de telefon nevalid, asigurați-vă că începe cu codul de țară corect.',
14 | ];
15 |
--------------------------------------------------------------------------------
/core/messages/tr/luya.php:
--------------------------------------------------------------------------------
1 | '{attribute}, minimum {length} karakter uzunluğunda olmalıdır.',
5 | '{attribute} must include at least one special character.' => '{attribute} en az bir özel karakter içermelidir.',
6 | '{attribute} must include at least one digit.' => '{attribute} en az bir rakam içermelidir.',
7 | '{attribute} must include at least one letter.' => '{attribute} en az bir harf içermelidir.',
8 | '{attribute} must include at least one uppercase letter.' => '{attribute}, en az bir büyük harf içermelidir.',
9 | '{attribute} must include at least one lowercase letter.' => '{attribute}, en az bir küçük harf içermelidir.',
10 | '{attribute} must be a float or numeric value.' => '{attribute}, bir float veya sayısal değer olmalıdır.'
11 | ];
12 |
--------------------------------------------------------------------------------
/core/resources/lazyload/intersectionOberserver.polyfill.unglue:
--------------------------------------------------------------------------------
1 | {
2 | "js" : [
3 | "intersectionObserver.polyfill.src.js"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/core/resources/lazyload/lazyload.unglue:
--------------------------------------------------------------------------------
1 | {
2 | "js": [
3 | "lazyload.src.js"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/core/resources/texttospeech/texttospeech.js:
--------------------------------------------------------------------------------
1 | !function($){$.textToSpeech=function(options){var settings=$.extend({text:"",playEvent:"textToSpeech:play",pauseEvent:"textToSpeech:pause",resumeEvent:"textToSpeech:resume",stopEvent:"textToSpeech:stop",errorEvent:"textToSpeech:error",finishedPlayingEvent:"textToSpeech:finished",eventSelector:"document",language:"en",favoriteVoice:""},options);if(!("speechSynthesis"in window))return!1;with(speechSynthesis)return{utterance:null,isPaused:!1,checkIfSpeakingInterval:null,play:function(){var t=this;if(this.isPaused)return this.resume();this.utterance=new SpeechSynthesisUtterance(settings.text),this.utterance.onerror=function(e){console.error(e),t.stop(),$(settings.eventSelector).trigger(settings.errorEvent)},$(window).on("beforeunload",function(){window.speechSynthesis.cancel()});try{window.speechSynthesis.cancel(),new Promise(function(e,t){var n=window.speechSynthesis.getVoices();0!==n.length?e(n):window.speechSynthesis.addEventListener("voiceschanged",function(){n=window.speechSynthesis.getVoices(),e(n)})}).then(function(e){t.utterance&&(t.utterance.voice=e.filter(function(e){return e.lang===settings.language})[0],t.utterance.voice=e.filter(function(e){return e.name===settings.favoriteVoice})[0],t.utterance.volume=1,t.utterance.rate=1,t.utterance.pitch=1,t.utterance.lang=settings.language,t.checkIfSpeaking(),window.speechSynthesis.speak(t.utterance),$(settings.eventSelector).trigger(settings.playEvent))})}catch(e){console.warn(e),this.stop()}},pause:function(){this.isPaused=!0,window.speechSynthesis.pause(),$(settings.eventSelector).trigger(settings.pauseEvent)},resume:function(){this.isPaused&&(this.isPaused=!1,window.speechSynthesis.resume(),$(settings.eventSelector).trigger(settings.resumeEvent))},stop:function(){this.checkIfSpeakingInterval&&clearInterval(this.checkIfSpeakingInterval),this.isPaused=!1,window.speechSynthesis.cancel(),$(settings.eventSelector).trigger(settings.stopEvent)},checkIfSpeaking:function(){var e=this;this.checkIfSpeakingInterval=setInterval(function(){!e.utterance||e.isPaused||window.speechSynthesis.speaking||e.stop()},500)},setText:function(e){settings.text=e},getText:function(){return settings.text}}}}(jQuery);
--------------------------------------------------------------------------------
/core/resources/texttospeech/texttospeech.unglue:
--------------------------------------------------------------------------------
1 | {
2 | "js" :
3 | [
4 | "texttospeech.src.js"
5 | ]
6 | }
--------------------------------------------------------------------------------
/core/rest/Controller.php:
--------------------------------------------------------------------------------
1 |
42 | * @since 1.0.0
43 | */
44 | class Controller extends \yii\rest\Controller
45 | {
46 | use RestBehaviorsTrait;
47 | }
48 |
--------------------------------------------------------------------------------
/core/rest/UserBehaviorInterface.php:
--------------------------------------------------------------------------------
1 | user;
20 | * }
21 | *
22 | * // Is action is now secured by the `app\models\User` model.
23 | * public function actionIndex()
24 | * {
25 | * return ['foo' => 'bar'];
26 | * }
27 | * }
28 | * ```
29 | *
30 | * @author Basil Suter
31 | * @since 1.0.0
32 | */
33 | interface UserBehaviorInterface
34 | {
35 | /**
36 | * Returns the class object for the authentication of the rest api. If the return value is false the authentication is disabled for the whole rest controller.
37 | *
38 | * return a user object (based on {{yii\web\User}}):
39 | *
40 | * ```php
41 | * return Yii::$app->adminuser;
42 | * ```
43 | *
44 | * return a class string will create a new object from this class string:
45 | *
46 | * ```php
47 | * return \luya\admin\components\AdminUser::class;
48 | * ```
49 | *
50 | * return false will disabled the authentication proccess for this rest controller:
51 | *
52 | * ```php
53 | * return false;
54 | * ```
55 | *
56 | * It can also be an array with configurations:
57 | *
58 | * ```php
59 | * return [
60 | * 'class' => 'app\models\User',
61 | * 'property1' => 'value',
62 | * ];
63 | * ```
64 | *
65 | * @return boolean|string|\yii\web\User If `false` is returned the protection is disabled, if a string is provided this will be threated as className to create the User object.
66 | */
67 | public function userAuthClass();
68 | }
69 |
--------------------------------------------------------------------------------
/core/tag/BaseTag.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.0
15 | */
16 | abstract class BaseTag extends BaseObject implements TagInterface
17 | {
18 | private $_view;
19 |
20 | /**
21 | * Get the view object to register assets in tags.
22 | *
23 | * @return \luya\web\View
24 | */
25 | public function getView()
26 | {
27 | if ($this->_view === null) {
28 | $this->_view = Yii::$app->getView();
29 | }
30 |
31 | return $this->_view;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/core/tag/TagInterface.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.0
10 | */
11 | interface TagInterface
12 | {
13 | /**
14 | * Provide a single example tag which is used as value when clicking on an tag in the administration interface
15 | * in order to insert the tag at the texteditor location.
16 | *
17 | * @return string The example string like `mail[info@luya.io](Mail us!)`.
18 | */
19 | public function example();
20 |
21 | /**
22 | * Get the readme informations of the current tag, markdown syntax is allowed.
23 | *
24 | * @return string The readme string with allowed markdown syntax.
25 | */
26 | public function readme();
27 |
28 | /**
29 | * Parse the the values of the tag into your output text.
30 | *
31 | * Assuming the following tag value `mytag[Hello](John Doe)`, the values are injected to `parse()` as following
32 | *
33 | * + **Hello** represents `$value` of the parse method.
34 | * + **John Doe** represents `$sub` of parse method.
35 | *
36 | * The `$sub` variables can also be null and is not required by any tag. Assuming `mytag[Hello]` means that `$sub` is null.
37 | *
38 | * The output of `parse()` is what will be replaced withing this tag. Assuming the above example `mytag[Hello](John Doe)` with the
39 | * parse logic:
40 | *
41 | * ```php
42 | * public function parse($value, $sub)
43 | * {
44 | * return "{$value}, {$sub}";
45 | * }
46 | * ```
47 | *
48 | * Woud replace and return tag with **Hello, John Doe**.
49 | *
50 | * @param string $value The value of the tag enclosed by square bracket `[]`
51 | * @param string|null $sub The optional value of the tag enclise by round bracket `()`, is not required by tag. If not provided equals `null`.
52 | * @return string The new generated string of the Tag.
53 | */
54 | public function parse($value, $sub);
55 | }
56 |
--------------------------------------------------------------------------------
/core/tag/TagMarkdownParser.php:
--------------------------------------------------------------------------------
1 | www.luya.io).
16 | *
17 | * @author Basil Suter
18 | * @since 1.0.0
19 | */
20 | class TagMarkdownParser extends GithubMarkdown
21 | {
22 | /**
23 | * @var boolean To convert all newlines to -tags. By default only newlines with two preceding spaces are converted to -tags.
24 | */
25 | public $enableNewlines = true;
26 |
27 | /**
28 | * Disable the url parsing of markdown.
29 | *
30 | * + https://luya.io
31 | * + www.luya.io
32 | *
33 | * Will not be parsed to an a tag.
34 | *
35 | * @param string $markdown
36 | * @return array|void
37 | */
38 | protected function parseUrl($markdown)
39 | {
40 | return;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/core/tag/tags/TelTag.php:
--------------------------------------------------------------------------------
1 |
16 | * @since 1.0.0
17 | */
18 | class TelTag extends BaseTag
19 | {
20 | /**
21 | * An example of how to use the TelTag.
22 | *
23 | * @return string The example string
24 | * @see \luya\tag\TagInterface::example()
25 | */
26 | public function example()
27 | {
28 | return 'tel[+41 123 45 65](Call us!)';
29 | }
30 |
31 | /**
32 | * The readme instructions string for the TelTag.
33 | *
34 | * @return string The readme text.
35 | * @see \luya\tag\TagInterface::readme()
36 | */
37 | public function readme()
38 | {
39 | return 'Generate a tel link which is commonly used on mobile websites in order create a click to call link. tel[+41 061 123 123] or with with a name instead of the phone number tel[+41 061 123 123](call us now!).';
40 | }
41 |
42 | /**
43 | * Generate the Tel Tag.
44 | *
45 | * @param string $value The Brackets value `[]`.
46 | * @param string $sub The optional Parentheses value `()`
47 | * @see \luya\tag\TagInterface::parse()
48 | * @return string The parser tag.
49 | */
50 | public function parse($value, $sub)
51 | {
52 | return Html::a(empty($sub) ? $value : $sub, 'tel:' . $this->ensureNumber($value));
53 | }
54 |
55 | private function ensureNumber($number)
56 | {
57 | if (!StringHelper::startsWith($number, '+')) {
58 | $number = '+'.$number;
59 | }
60 |
61 | return str_replace(" ", "", $number);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/core/texttospeech/TextToSpeechAsset.php:
--------------------------------------------------------------------------------
1 |
11 | * @author Basil Suter
12 | * @since 1.1.0
13 | */
14 | class TextToSpeechAsset extends Asset
15 | {
16 | /**
17 | * @var string The path to the source files of the asset.
18 | */
19 | public $sourcePath = '@luya/resources/texttospeech';
20 |
21 | /**
22 | * @var array An array with all javascript files for this asset located in the source path folder.
23 | */
24 | public $js = [
25 | YII_DEBUG ? 'texttospeech.src.js' : 'texttospeech.js',
26 | ];
27 |
28 | /**
29 | * @var array An array with assets this asset depends on.
30 | */
31 | public $depends = [
32 | 'yii\web\JqueryAsset',
33 | ];
34 | }
35 |
--------------------------------------------------------------------------------
/core/texttospeech/views/texttospeech.php:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/core/theme/SetupEvent.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.1.0
12 | */
13 | class SetupEvent extends Event
14 | {
15 | /**
16 | * @var string Base path of the theme to setup.
17 | */
18 | public $basePath;
19 | }
20 |
--------------------------------------------------------------------------------
/core/traits/NextPrevModel.php:
--------------------------------------------------------------------------------
1 |
12 | * @since 1.0.0
13 | */
14 | trait NextPrevModel
15 | {
16 | /**
17 | * Get the next actrive record of the current id
18 | *
19 | * @return ActiveQuery
20 | */
21 | public function getNext()
22 | {
23 | return self::find()->where(['>', 'id', $this->id])->limit(1)->one();
24 | }
25 |
26 | /**
27 | * Get the previous record of a current id
28 | *
29 | * @return ActiveQuery
30 | */
31 | public function getPrev()
32 | {
33 | return self::find()->where(['<', 'id', $this->id])->orderBy(['id' => SORT_DESC])->limit(1)->one();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/core/validators/FloatValidator.php:
--------------------------------------------------------------------------------
1 |
31 | * @author Martin Petrasch
32 | * @since 1.0.0
33 | */
34 | class FloatValidator extends Validator
35 | {
36 | /**
37 | * @var string The messaged to send when an error appears.
38 | */
39 | public $message = '{attribute} must be a float or numeric value.';
40 |
41 | /**
42 | * Validate the value if is_numeric or if not is_float.
43 | *
44 | * @see \yii\validators\Validator::validateAttribute()
45 | */
46 | public function validateAttribute($model, $attribute)
47 | {
48 | $value = $model->$attribute;
49 | if (!is_numeric($value) && !is_float($value)) {
50 | return $model->addError($attribute, Yii::t('luya', $this->message, ['attribute' => $model->getAttributeLabel($attribute)]));
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/core/web/Asset.php:
--------------------------------------------------------------------------------
1 |
17 | * @since 1.0.0
18 | */
19 | class Asset extends \yii\web\AssetBundle
20 | {
21 | /**
22 | * @var string When $sourcePath is null, the Asset object will automatically assign this folder relative to its object.
23 | * @since 1.1.0
24 | */
25 | public $defaultSourcePathFolder = 'resources';
26 |
27 | public function init()
28 | {
29 | parent::init();
30 |
31 | if ($this->sourcePath === null) {
32 | $class = new ReflectionClass($this);
33 | $this->sourcePath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $this->defaultSourcePathFolder . DIRECTORY_SEPARATOR . Inflector::camel2id($class->getShortName());
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/web/AssetManager.php:
--------------------------------------------------------------------------------
1 |
12 | * @since 1.0.0
13 | */
14 | class AssetManager extends \yii\web\AssetManager
15 | {
16 | }
17 |
--------------------------------------------------------------------------------
/core/web/BaseLink.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 1.0.10
16 | */
17 | abstract class BaseLink extends BaseObject implements LinkInterface, Arrayable
18 | {
19 | use LinkTrait;
20 | use ArrayableTrait;
21 |
22 | /**
23 | * @inheritdoc
24 | */
25 | public function fields()
26 | {
27 | return ['href', 'target'];
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/web/EmailLink.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.0
15 | */
16 | class EmailLink extends BaseLink
17 | {
18 | private $_email;
19 |
20 | /**
21 | * @inheritdoc
22 | */
23 | public function init()
24 | {
25 | parent::init();
26 |
27 | if ($this->email === null) {
28 | throw new InvalidConfigException('The email attribute can not be empty and must be set trough configuration array.');
29 | }
30 | }
31 |
32 | /**
33 | * Setter method for e-mail.
34 | *
35 | * If no valid email is provided, not value is set.
36 | *
37 | * @param string $email The e-mail which should be used for the mailto link.
38 | */
39 | public function setEmail($email)
40 | {
41 | $validator = new EmailValidator();
42 | if ($validator->validate($email)) {
43 | $this->_email = $email;
44 | } else {
45 | $this->_email = false;
46 | }
47 | }
48 |
49 | /**
50 | * Getter method for the e-mail.
51 | *
52 | * @return string|boolean Returns the e-mail from the setter method, if mail is not valid false is returned.
53 | */
54 | public function getEmail()
55 | {
56 | return $this->_email;
57 | }
58 |
59 | /**
60 | * @inheritdoc
61 | */
62 | public function getHref()
63 | {
64 | return empty($this->getEmail()) ? null : 'mailto:' . $this->getEmail();
65 | }
66 |
67 | /**
68 | * @inheritdoc
69 | */
70 | public function getTarget()
71 | {
72 | return '_blank';
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/core/web/ErrorHandler.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | class ErrorHandler extends \yii\web\ErrorHandler
14 | {
15 | use ErrorHandlerTrait {
16 | renderException as protected traitRenderException;
17 | }
18 | /**
19 | * @var string Event will be trigger before the ErrorHandler starts to render the exception.
20 | */
21 | public const EVENT_BEFORE_EXCEPTION_RENDER = 'onBeforeExceptionRender';
22 |
23 | /**
24 | * @inheritdoc
25 | */
26 | public function renderException($exception)
27 | {
28 | $event = new ErrorHandlerExceptionRenderEvent();
29 | $event->exception = $exception;
30 | $this->trigger(self::EVENT_BEFORE_EXCEPTION_RENDER, $event);
31 |
32 | return $this->traitRenderException($exception);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/core/web/ErrorHandlerExceptionRenderEvent.php:
--------------------------------------------------------------------------------
1 |
15 | * @since 1.0.0
16 | */
17 | class ErrorHandlerExceptionRenderEvent extends Event
18 | {
19 | /**
20 | * @var \yii\base\Exception
21 | */
22 | public $exception;
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/GroupUserIdentityInterface.php:
--------------------------------------------------------------------------------
1 | The GroupUserIdentityInterface extends the {{yii\web\IdentityInterface}} Interface.
13 | *
14 | * ```php
15 | * class User extends ActiveRecord implements GroupUserIdentityInterface
16 | * {
17 | * // luya\web\GroupUserIdentityInterface
18 | *
19 | * public function authGroups()
20 | * {
21 | * return [
22 | * 'group-a',
23 | * ];
24 | * }
25 | *
26 | * // yii\web\IdentityInterface
27 | *
28 | * public static function findIdentity($id)
29 | * {
30 | * return static::findOne($id);
31 | * }
32 | *
33 | * public static function findIdentityByAccessToken($token, $type = null)
34 | * {
35 | * return static::findOne(['access_token' => $token]);
36 | * }
37 | *
38 | * public function getId()
39 | * {
40 | * return $this->id;
41 | * }
42 | *
43 | * public function getAuthKey()
44 | * {
45 | * return $this->authKey;
46 | * }
47 | *
48 | * public function validateAuthKey($authKey)
49 | * {
50 | * return $this->authKey === $authKey;
51 | * }
52 | * }
53 | * ```
54 | *
55 | * @author Basil Suter
56 | * @since 1.0.0
57 | */
58 | interface GroupUserIdentityInterface extends IdentityInterface
59 | {
60 | /**
61 | * Returns an array with group aliases allowed for the current user.
62 | *
63 | * ```php
64 | * public function authGroups()
65 | * {
66 | * return [
67 | * 'group-a', 'group-c',
68 | * ];
69 | * }
70 | * ```
71 | *
72 | * @return array An array contains the allowed groups for this user.
73 | */
74 | public function authGroups();
75 | }
76 |
--------------------------------------------------------------------------------
/core/web/LinkInterface.php:
--------------------------------------------------------------------------------
1 | getHref(); ?>" target="= $object->getTarget(); ?>">Go To
12 | * ```
13 | *
14 | * When implementing the LinkInterface its very common to also use the {{luya\web\LinkTrait}}.
15 | *
16 | * @author Basil Suter
17 | * @since 1.0.0
18 | */
19 | interface LinkInterface
20 | {
21 | /**
22 | * Get the href attribute value inside the Link tag.
23 | *
24 | * @return string Returns the href string which can be either with or without domain.
25 | */
26 | public function getHref();
27 |
28 | /**
29 | * Get the target attribute value inside the Link tag.
30 | *
31 | * Can be either _blank, _self.
32 | *
33 | * @return string Returns the target string value for the link resource.
34 | */
35 | public function getTarget();
36 | }
37 |
--------------------------------------------------------------------------------
/core/web/LinkTrait.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.0
12 | */
13 | trait LinkTrait
14 | {
15 | /**
16 | * Return the href string from getHref() when echoing the object.
17 | */
18 | public function __toString()
19 | {
20 | return $this->getHref();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/core/web/UrlRule.php:
--------------------------------------------------------------------------------
1 | '\luya\web\UrlRule'];
13 | * ```
14 | *
15 | * @author Basil Suter
16 | * @since 1.0.0
17 | */
18 | class UrlRule extends \yii\web\UrlRule
19 | {
20 | /**
21 | * @var array Composition rules are multi lingual rule definitions match against different
22 | * languages from composition component. This variable will be assigned from the modules urlRule
23 | * variable and while foreaching the urlRules the composition values for each rule will be stored
24 | * in this variable to retrieve the informations later on.
25 | */
26 | public $composition = [];
27 | }
28 |
--------------------------------------------------------------------------------
/core/web/jsonld/AggregateRating.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class AggregateRating extends Rating
13 | {
14 | /**
15 | * @inheritdoc
16 | */
17 | public function typeDefintion()
18 | {
19 | return 'AggregateRating';
20 | }
21 |
22 | private $_itemReviewed;
23 |
24 | /**
25 | * Set item reviewed
26 | *
27 | * @param ThingInterface $thing
28 | * @return static
29 | */
30 | public function setItemReviewed(ThingInterface $thing)
31 | {
32 | $this->_itemReviewed = $thing;
33 | return $this;
34 | }
35 |
36 | /**
37 | * Getter item reviewed
38 | *
39 | * @return ThingInterface
40 | */
41 | public function getItemReviewed()
42 | {
43 | return $this->_itemReviewed;
44 | }
45 |
46 | private $_ratingCount;
47 |
48 | /**
49 | * Set rating count
50 | *
51 | * @param integer $ratingCount
52 | * @return static
53 | */
54 | public function setRatingCount($ratingCount)
55 | {
56 | $this->_ratingCount = (int) $ratingCount;
57 | return $this;
58 | }
59 |
60 | /**
61 | * Get Rating count
62 | *
63 | * @return integer
64 | */
65 | public function getRatingCount()
66 | {
67 | return $this->_ratingCount;
68 | }
69 |
70 | private $_reviewCount;
71 |
72 | /**
73 | * Set Review Count
74 | *
75 | * @param integer $reviewCount
76 | * @return static
77 | */
78 | public function setReviewCount($reviewCount)
79 | {
80 | $this->_reviewCount = (int) $reviewCount;
81 | return $this;
82 | }
83 |
84 | /**
85 | * Get Review count
86 | *
87 | * @return integer
88 | */
89 | public function getReviewCount()
90 | {
91 | return $this->_reviewCount;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/core/web/jsonld/Article.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.1
15 | */
16 | class Article extends BaseThing implements ArticleInterface
17 | {
18 | use ArticleTrait;
19 | /**
20 | * @inheritdoc
21 | */
22 | public function typeDefintion()
23 | {
24 | return 'Article';
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/core/web/jsonld/ArticleInterface.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.1
12 | */
13 | interface ArticleInterface extends CreativeWorkInterface
14 | {
15 | /**
16 | * @return string
17 | */
18 | public function getArticleBody();
19 |
20 | /**
21 | * @param string $articleBody
22 | * @return static
23 | */
24 | public function setArticleBody($articleBody);
25 |
26 | /**
27 | * @return string
28 | */
29 | public function getArticleSection();
30 |
31 | /**
32 | * @param string $articleSection
33 | * @return static
34 | */
35 | public function setArticleSection($articleSection);
36 |
37 | /**
38 | * @return int|string
39 | */
40 | public function getPageEnd();
41 |
42 | /**
43 | * @param int|string $pageEnd
44 | * @return static
45 | */
46 | public function setPageEnd($pageEnd);
47 |
48 | /**
49 | * @return int|string
50 | */
51 | public function getPageStart();
52 |
53 | /**
54 | * @param int|string $pageStart
55 | * @return static
56 | */
57 | public function setPageStart($pageStart);
58 |
59 | /**
60 | * @return string
61 | */
62 | public function getPagination();
63 |
64 | /**
65 | * @param string $pagination
66 | * @return static
67 | */
68 | public function setPagination($pagination);
69 |
70 |
71 | /**
72 | * @return int
73 | */
74 | public function getWordCount();
75 |
76 | /**
77 | * @param int $wordCount
78 | * @return static
79 | */
80 | public function setWordCount($wordCount);
81 | }
82 |
--------------------------------------------------------------------------------
/core/web/jsonld/BarOrPub.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | class BarOrPub extends FoodEstablishment
12 | {
13 | /**
14 | * {@inheritDoc}
15 | */
16 | public function typeDefintion()
17 | {
18 | return 'BarOrPub';
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/web/jsonld/BaseValue.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.3
12 | */
13 | abstract class BaseValue
14 | {
15 | /**
16 | * Get the value to assign from BaseValue.
17 | */
18 | abstract public function getValue();
19 | }
20 |
--------------------------------------------------------------------------------
/core/web/jsonld/BlogPosting.php:
--------------------------------------------------------------------------------
1 |
13 | * @since 1.0.1
14 | */
15 | class BlogPosting extends BaseThing implements BlogPostingInterface
16 | {
17 | use BlogPostingTrait;
18 | /**
19 | * @inheritdoc
20 | */
21 | public function typeDefintion()
22 | {
23 | return 'BlogPosting';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/web/jsonld/BlogPostingInterface.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.1
12 | */
13 | interface BlogPostingInterface extends SocialMediaPostingInterface
14 | {
15 | }
16 |
--------------------------------------------------------------------------------
/core/web/jsonld/BlogPostingTrait.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.1
12 | */
13 | trait BlogPostingTrait
14 | {
15 | use SocialMediaPostingTrait;
16 | }
17 |
--------------------------------------------------------------------------------
/core/web/jsonld/CafeOrCoffeeShop.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | class CafeOrCoffeeShop extends FoodEstablishment
12 | {
13 | /**
14 | * {@inheritDoc}
15 | */
16 | public function typeDefintion()
17 | {
18 | return 'CafeOrCoffeeShop';
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/web/jsonld/Comment.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class Comment extends BaseThing implements CommentInterface
13 | {
14 | use CommentTrait;
15 |
16 | /**
17 | * @inheritdoc
18 | */
19 | public function typeDefintion()
20 | {
21 | return 'Comment';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/jsonld/CommentInterface.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | interface CommentInterface extends CreativeWorkInterface
13 | {
14 | }
15 |
--------------------------------------------------------------------------------
/core/web/jsonld/CommentTrait.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | trait CommentTrait
13 | {
14 | use CreativeWorkTrait;
15 | }
16 |
--------------------------------------------------------------------------------
/core/web/jsonld/Country.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class Country extends BaseThing implements CountryInterface
13 | {
14 | use CountryTrait;
15 |
16 | /**
17 | * @inheritdoc
18 | */
19 | public function typeDefintion()
20 | {
21 | return 'Country';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/jsonld/CountryInterface.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | interface CountryInterface extends PlaceInterface
13 | {
14 | }
15 |
--------------------------------------------------------------------------------
/core/web/jsonld/CountryTrait.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | trait CountryTrait
13 | {
14 | use PlaceTrait;
15 | }
16 |
--------------------------------------------------------------------------------
/core/web/jsonld/CreativeWork.php:
--------------------------------------------------------------------------------
1 |
13 | * @since 1.0.1
14 | */
15 | class CreativeWork extends BaseThing implements CreativeWorkInterface
16 | {
17 | use CreativeWorkTrait;
18 | /**
19 | * @inheritdoc
20 | */
21 | public function typeDefintion()
22 | {
23 | return 'CreativeWork';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/web/jsonld/CurrencyValue.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.14
15 | */
16 | class CurrencyValue extends BaseValue
17 | {
18 | private $_currency;
19 |
20 | public function __construct($currency)
21 | {
22 | if (strlen($currency) !== 3) {
23 | throw new InvalidConfigException("The currency value must have 3 letter code like USD, CHF. Value \"{$currency}\" given.");
24 | }
25 |
26 | $this->_currency = $currency;
27 | }
28 |
29 | public function getValue()
30 | {
31 | return strtoupper($this->_currency);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/core/web/jsonld/DateTimeValue.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.3
10 | */
11 | class DateTimeValue extends BaseValue
12 | {
13 | private $_datetime;
14 |
15 | /**
16 | * Provide datetime value.
17 | *
18 | * @param string|integer $datetime
19 | */
20 | public function __construct($datetime)
21 | {
22 | $this->_datetime = $datetime;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | public function getValue()
29 | {
30 | if (is_numeric($this->_datetime)) {
31 | $this->_datetime = date("c", $this->_datetime);
32 | }
33 |
34 | return $this->_datetime;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/web/jsonld/DateValue.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.3
12 | */
13 | class DateValue extends BaseValue
14 | {
15 | private $_date;
16 |
17 | /**
18 | * Provide date data.
19 | *
20 | * @param string|integer $date
21 | */
22 | public function __construct($date)
23 | {
24 | $this->_date = $date;
25 | }
26 |
27 | /**
28 | * @inheritDoc
29 | */
30 | public function getValue()
31 | {
32 | if (is_numeric($this->_date)) {
33 | $this->_date = date("Y-m-d", $this->_date);
34 | }
35 |
36 | return $this->_date;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/web/jsonld/EntertainmentBusiness.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | class EntertainmentBusiness extends LocalBusiness
12 | {
13 | /**
14 | * {@inheritDoc}
15 | */
16 | public function typeDefintion()
17 | {
18 | return 'EntertainmentBusiness';
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/web/jsonld/Event.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | class FoodEstablishment extends LocalBusiness implements FoodEstablishmentInterface
12 | {
13 | use FoodEstablishmentTrait;
14 |
15 | /**
16 | * {@inheritDoc}
17 | */
18 | public function typeDefintion()
19 | {
20 | return 'FoodEstablishment';
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/core/web/jsonld/FoodEstablishmentInterface.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | interface FoodEstablishmentInterface
12 | {
13 | /**
14 | * Accepts Reservations
15 | *
16 | * @param string $acceptsReservations
17 | * @return static
18 | */
19 | public function setAcceptsReservations($acceptsReservations);
20 |
21 | /**
22 | * Get Accepts Reserverations
23 | *
24 | * @return string
25 | */
26 | public function getAcceptsReservations();
27 |
28 | /**
29 | * Set has menu
30 | *
31 | * @param string $hasMenu
32 | * @return static
33 | */
34 | public function setHasMenu($hasMenu);
35 |
36 | /**
37 | * Get Has menu
38 | *
39 | * @return string
40 | */
41 | public function getHasMenu();
42 |
43 | /**
44 | * Set Serves Cuisine
45 | *
46 | * @param string $servesCuisine
47 | * @return static
48 | */
49 | public function setServesCuisine($servesCuisine);
50 |
51 | /**
52 | * Get serves Cuisine
53 | *
54 | * @return string
55 | */
56 | public function getServesCuisine();
57 |
58 | /**
59 | * Set Star Rating
60 | *
61 | * @param Rating $rating
62 | * @return static
63 | */
64 | public function setStarRating(Rating $rating);
65 |
66 | /**
67 | * Get Star Rating
68 | *
69 | * @return Rating
70 | */
71 | public function getStarRating();
72 | }
73 |
--------------------------------------------------------------------------------
/core/web/jsonld/ImageObject.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class ImageObject extends BaseThing implements ImageObjectInterface
13 | {
14 | use ImageObjectTrait;
15 |
16 | /**
17 | * @inheritdoc
18 | */
19 | public function typeDefintion()
20 | {
21 | return 'ImageObject';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/jsonld/ImageObjectInterface.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | interface ImageObjectInterface extends MediaObjectInterface
13 | {
14 | /**
15 | * Setter methdo for Caption.
16 | *
17 | * @param string $caption
18 | * @return static
19 | */
20 | public function setCaption($caption);
21 |
22 | /**
23 | * Getter method for Caption.
24 | */
25 | public function getCaption();
26 |
27 | /**
28 | * Setter method for exif data via PropertyValue.
29 | *
30 | * @param PropertyValue $propertyValue
31 | * @return static
32 | */
33 | public function setExifData(PropertyValue $propertyValue);
34 |
35 | /**
36 | * Getter method for exit data.
37 | */
38 | public function getExifData();
39 |
40 | /**
41 | * Setter method for representative of page value
42 | *
43 | * @param string $representativeOfPage
44 | * @return static
45 | */
46 | public function setRepresentativeOfPage($representativeOfPage);
47 |
48 | /**
49 | * Getter method for representative of page value
50 | */
51 | public function getRepresentativeOfPage();
52 |
53 | /**
54 | * Setter method for Thumbnail.
55 | *
56 | * @param ImageObject $imageObject
57 | * @return static
58 | */
59 | public function setThumbnail(ImageObject $imageObject);
60 |
61 | /**
62 | * Getter method for thumbnail.
63 | */
64 | public function getThumbnail();
65 | }
66 |
--------------------------------------------------------------------------------
/core/web/jsonld/ImageObjectTrait.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | trait ImageObjectTrait
13 | {
14 | use MediaObjectTrait;
15 |
16 | private $_caption;
17 |
18 | /**
19 | *
20 | * @return static
21 | */
22 | public function setCaption($caption)
23 | {
24 | $this->_caption = $caption;
25 | return $this;
26 | }
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | public function getCaption()
32 | {
33 | return $this->_caption;
34 | }
35 |
36 | private $_exifData;
37 |
38 | /**
39 | *
40 | * @return static
41 | */
42 | public function setExifData(PropertyValue $propertyValue)
43 | {
44 | $this->_exifData = $propertyValue;
45 |
46 | return $this;
47 | }
48 |
49 | /**
50 | * @inheritDoc
51 | */
52 | public function getExifData()
53 | {
54 | return $this->_exifData;
55 | }
56 |
57 | private $_representativeOfPage;
58 |
59 | /**
60 | *
61 | * @return static
62 | */
63 | public function setRepresentativeOfPage($representativeOfPage)
64 | {
65 | $this->_representativeOfPage = $representativeOfPage;
66 |
67 | return $this;
68 | }
69 |
70 | /**
71 | * @inheritDoc
72 | */
73 | public function getRepresentativeOfPage()
74 | {
75 | return $this->_representativeOfPage;
76 | }
77 |
78 | private $_thumbnail;
79 |
80 | /**
81 | *
82 | * @return static
83 | */
84 | public function setThumbnail(ImageObject $imageObject)
85 | {
86 | $this->_thumbnail = $imageObject;
87 |
88 | return $this;
89 | }
90 |
91 | /**
92 | * @inheritDoc
93 | */
94 | public function getThumbnail()
95 | {
96 | return $this->_thumbnail;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/core/web/jsonld/LanguageValue.php:
--------------------------------------------------------------------------------
1 |
13 | * @since 1.0.14
14 | */
15 | class LanguageValue extends BaseValue
16 | {
17 | private $_language;
18 |
19 | public function __construct($langauge)
20 | {
21 | $this->_language = $langauge;
22 | }
23 |
24 | public function getValue()
25 | {
26 | // RFC VALIDATION
27 | return $this->_language;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/web/jsonld/LiveBlogPosting.php:
--------------------------------------------------------------------------------
1 |
13 | * @since 1.0.1
14 | */
15 | class LiveBlogPosting extends BaseThing implements LiveBlogPostingInterface
16 | {
17 | use LiveBlogPostingTrait;
18 | /**
19 | * @inheritdoc
20 | */
21 | public function typeDefintion()
22 | {
23 | return 'LiveBlogPosting';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/web/jsonld/LiveBlogPostingInterface.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.1
12 | */
13 | interface LiveBlogPostingInterface extends BlogPostingInterface
14 | {
15 | /**
16 | * @return string
17 | */
18 | public function getCoverageEndTime();
19 |
20 | /**
21 | * @param DateTimeValue $coverageEndTime
22 | * @return static
23 | */
24 | public function setCoverageEndTime(DateTimeValue $coverageEndTime);
25 |
26 | /**
27 | * @return string
28 | */
29 | public function getCoverageStartTime();
30 |
31 | /**
32 | * @param DateTimeValue $coverageStartTime
33 | * @return static
34 | */
35 | public function setCoverageStartTime(DateTimeValue $coverageStartTime);
36 |
37 | /**
38 | * @return BlogPosting
39 | */
40 | public function getLiveBlogUpdate();
41 |
42 | /**
43 | * @param BlogPosting $liveBlogUpdate
44 | * @return static
45 | */
46 | public function setLiveBlogUpdate(BlogPosting $liveBlogUpdate);
47 | }
48 |
--------------------------------------------------------------------------------
/core/web/jsonld/LocalBusiness.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.14
12 | */
13 | class LocalBusiness extends Organization implements LocalBusinessInterface, OrganizationInterface, PlaceInterface
14 | {
15 | use LocalBusinessTrait;
16 | use PlaceTrait;
17 |
18 | /**
19 | * {@inheritDoc}
20 | */
21 | public function typeDefintion()
22 | {
23 | return 'LocalBusiness';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/web/jsonld/LocalBusinessInterface.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | interface LocalBusinessInterface
12 | {
13 | /**
14 | * Set accepted currencies
15 | *
16 | * @param CurrencyValue $currency
17 | * @return static
18 | */
19 | public function setCurrenciesAccepted(CurrencyValue $currency);
20 |
21 | /**
22 | * Get accepted currencies
23 | *
24 | * @return string
25 | */
26 | public function getCurrenciesAccepted();
27 |
28 | /**
29 | * Set Opening Hours
30 | *
31 | * @param OpeningHoursValue $openingHours
32 | * @return static
33 | */
34 | public function setOpeningHours(OpeningHoursValue $openingHours);
35 |
36 | /**
37 | * Get opening hours
38 | *
39 | * @return string
40 | */
41 | public function getOpeningHours();
42 |
43 | /**
44 | * Set Payment Accepted
45 | *
46 | * @param string $payment
47 | * @return static
48 | */
49 | public function setPaymentAccepted($payment);
50 |
51 | /**
52 | * Get payment Accepted
53 | *
54 | * @return string
55 | */
56 | public function getPaymentAccepted();
57 |
58 | /**
59 | * Set Price range
60 | *
61 | * @param string $priceRange
62 | * @return static
63 | */
64 | public function setPriceRange($priceRange);
65 |
66 | /**
67 | * Get price range
68 | *
69 | * @return string
70 | */
71 | public function getPriceRange();
72 | }
73 |
--------------------------------------------------------------------------------
/core/web/jsonld/MediaObject.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class MediaObject extends BaseThing implements MediaObjectInterface
13 | {
14 | use MediaObjectTrait;
15 |
16 | /**
17 | * @inheritdoc
18 | */
19 | public function typeDefintion()
20 | {
21 | return 'MediaObject';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/jsonld/MediaObjectInterface.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | interface MediaObjectInterface extends CreativeWorkInterface
13 | {
14 | /**
15 | * Actual bytes of the media object, for example the image file or video file.
16 | *
17 | * @param UrlValue $url
18 | * @return static
19 | */
20 | public function setContentUrl(UrlValue $url);
21 |
22 | /**
23 | * Getter method for contentUrl.
24 | */
25 | public function getContentUrl();
26 |
27 | /**
28 | * A URL pointing to a player for a specific video. In general, this is the information in the src element of an embed tag and should not be the same as the content of the loc tag.
29 | *
30 | * @param UrlValue $url
31 | * @return static
32 | */
33 | public function setEmbedUrl(UrlValue $url);
34 |
35 | /**
36 | * Getter method for embedUrl.
37 | */
38 | public function getEmbedUrl();
39 |
40 | /**
41 | * Date when this media object was uploaded to this site.
42 | * @param DateValue $date
43 | * @return static
44 | */
45 | public function setUploadDate(DateValue $date);
46 |
47 | /**
48 | * Getter method for uploadDate.
49 | */
50 | public function getUploadDate();
51 | }
52 |
--------------------------------------------------------------------------------
/core/web/jsonld/MediaObjectTrait.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | trait MediaObjectTrait
13 | {
14 | use CreativeWorkTrait;
15 |
16 | private $_contentUrl;
17 |
18 | /**
19 | * @inheritdoc
20 | *
21 | * @return static
22 | */
23 | public function setContentUrl(UrlValue $url)
24 | {
25 | $this->_contentUrl = $url->getValue();
26 | return $this;
27 | }
28 |
29 | /**
30 | * @inheritdoc
31 | */
32 | public function getContentUrl()
33 | {
34 | return $this->_contentUrl;
35 | }
36 |
37 | private $_embedUrl;
38 |
39 | /**
40 | * @inheritdoc
41 | *
42 | * @return static
43 | */
44 | public function setEmbedUrl(UrlValue $url)
45 | {
46 | $this->_embedUrl = $url->getValue();
47 | return $this;
48 | }
49 |
50 | /**
51 | * @inheritdoc
52 | */
53 | public function getEmbedUrl()
54 | {
55 | return $this->_embedUrl;
56 | }
57 |
58 | private $_uploadDate;
59 |
60 | /**
61 | * @inheritdoc
62 | *
63 | * @return static
64 | */
65 | public function setUploadDate(DateValue $date)
66 | {
67 | $this->_uploadDate = $date->getValue();
68 | return $this;
69 | }
70 |
71 | /**
72 | * @inheritdoc
73 | */
74 | public function getUploadDate()
75 | {
76 | return $this->_uploadDate;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/core/web/jsonld/NightClub.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | class NightClub extends EntertainmentBusiness
12 | {
13 | /**
14 | * {@inheritDoc}
15 | */
16 | public function typeDefintion()
17 | {
18 | return 'NightClub';
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/web/jsonld/Offer.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class Offer extends BaseThing implements OfferInterface
13 | {
14 | use OfferTrait;
15 |
16 | /**
17 | * @inheritdoc
18 | */
19 | public function typeDefintion()
20 | {
21 | return 'Offer';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/jsonld/OfferInterface.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | interface OfferInterface extends ThingInterface
13 | {
14 | /**
15 | * Price Setter
16 | *
17 | * @param PriceValue $price
18 | * @return static
19 | * @since 1.2.2
20 | */
21 | public function setPrice(PriceValue $price);
22 |
23 | /**
24 | * Price Getter
25 | *
26 | * @return mixed
27 | * @since 1.2.2
28 | */
29 | public function getPrice();
30 |
31 | /**
32 | * Price Currency Setter.
33 | *
34 | * @param CurrencyValue $currencyValue
35 | * @return static
36 | * @since 1.2.2
37 | */
38 | public function setPriceCurrency(CurrencyValue $currencyValue);
39 |
40 | /**
41 | * Price Currency Getter
42 | *
43 | * @return string
44 | * @since 1.2.2
45 | */
46 | public function getPriceCurrency();
47 | }
48 |
--------------------------------------------------------------------------------
/core/web/jsonld/OfferTrait.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | trait OfferTrait
13 | {
14 | use ThingTrait;
15 |
16 | private $_availability;
17 |
18 | private $_price;
19 |
20 | /**
21 | * Price Setter
22 | *
23 | * @param PriceValue $price
24 | * @return static
25 | * @since 1.2.2
26 | */
27 | public function setPrice(PriceValue $price)
28 | {
29 | $this->_price = $price->getValue();
30 | return $this;
31 | }
32 |
33 | /**
34 | * Get Price
35 | *
36 | * @return mixed
37 | * @since 1.2.2
38 | */
39 | public function getPrice()
40 | {
41 | return $this->_price;
42 | }
43 |
44 | private $_priceCurrency;
45 |
46 | /**
47 | * Price Currency Setter.
48 | *
49 | * @param CurrencyValue $currencyValue
50 | * @return static
51 | * @since 1.2.2
52 | */
53 | public function setPriceCurrency(CurrencyValue $currencyValue)
54 | {
55 | $this->_priceCurrency = $currencyValue->getValue();
56 | return $this;
57 | }
58 |
59 | /**
60 | * Get Price Currency
61 | *
62 | * @return string
63 | * @since 1.2.2
64 | */
65 | public function getPriceCurrency()
66 | {
67 | return $this->_priceCurrency;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/core/web/jsonld/Organization.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.2.2
12 | */
13 | class PriceValue extends BaseValue
14 | {
15 | private $_price;
16 |
17 | public function __construct($price)
18 | {
19 | $this->_price = $price;
20 | }
21 |
22 | public function getValue()
23 | {
24 | return str_replace(",", ".", $this->_price);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/core/web/jsonld/PropertyValue.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class PropertyValue extends BaseThing implements PropertyValueInterface
13 | {
14 | use PropertyValueTrait;
15 |
16 | /**
17 | * @inheritdoc
18 | */
19 | public function typeDefintion()
20 | {
21 | return 'PropertyValue';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/web/jsonld/RangeValue.php:
--------------------------------------------------------------------------------
1 | _value = $value;
14 | }
15 |
16 | public function ensureRange($min, $max)
17 | {
18 | if ($this->_value < $min || $this->_value > $max) {
19 | throw new InvalidConfigException("Value {$this->_value} must be min {$min} or max {$max}.");
20 | }
21 | }
22 |
23 | public function getValue()
24 | {
25 | return $this->_value;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/core/web/jsonld/Restaurant.php:
--------------------------------------------------------------------------------
1 |
9 | * @since 1.0.14
10 | */
11 | class Restaurant extends FoodEstablishment
12 | {
13 | /**
14 | * {@inheritDoc}
15 | */
16 | public function typeDefintion()
17 | {
18 | return 'Restaurant';
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/web/jsonld/SocialMediaPosting.php:
--------------------------------------------------------------------------------
1 |
13 | * @since 1.0.1
14 | */
15 | class SocialMediaPosting extends BaseThing implements SocialMediaPostingInterface
16 | {
17 | use SocialMediaPostingTrait;
18 | /**
19 | * @inheritdoc
20 | */
21 | public function typeDefintion()
22 | {
23 | return 'SocialMediaPosting';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/web/jsonld/SocialMediaPostingInterface.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.1
12 | */
13 | interface SocialMediaPostingInterface extends ArticleInterface
14 | {
15 | /**
16 | * @return CreativeWork
17 | */
18 | public function getSharedContent();
19 |
20 | /**
21 | * @param CreativeWork $sharedContent
22 | * @return static
23 | */
24 | public function setSharedContent(CreativeWork $sharedContent);
25 | }
26 |
--------------------------------------------------------------------------------
/core/web/jsonld/SocialMediaPostingTrait.php:
--------------------------------------------------------------------------------
1 |
11 | * @since 1.0.1
12 | */
13 | trait SocialMediaPostingTrait
14 | {
15 | use ArticleTrait;
16 |
17 | private $_sharedContent;
18 |
19 | /**
20 | * @return CreativeWork
21 | */
22 | public function getSharedContent()
23 | {
24 | return $this->_sharedContent;
25 | }
26 |
27 | /**
28 | * A CreativeWork such as an image, video, or audio clip shared as part of this posting.
29 | *
30 | * @param CreativeWork $sharedContent
31 | * @return static
32 | */
33 | public function setSharedContent(CreativeWork $sharedContent)
34 | {
35 | $this->_sharedContent = $sharedContent;
36 | return $this;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/web/jsonld/TextValue.php:
--------------------------------------------------------------------------------
1 |
14 | * @since 1.0.3
15 | */
16 | class TextValue extends BaseValue
17 | {
18 | private $_text;
19 |
20 | /**
21 | * Provide date data.
22 | *
23 | * @param string|integer $date
24 | */
25 | public function __construct($text)
26 | {
27 | $this->_text = $text;
28 | }
29 |
30 | /**
31 | * Truncate the string for a given lenth.
32 | *
33 | * @param integer $length
34 | * @return \luya\web\jsonld\TextValue
35 | */
36 | public function truncate($length)
37 | {
38 | $this->_text = StringHelper::truncate($this->_text, $length);
39 |
40 | return $this;
41 | }
42 |
43 | /**
44 | * Html encode the text data.
45 | *
46 | * @return \luya\web\jsonld\TextValue
47 | */
48 | public function encode()
49 | {
50 | $this->_text = Html::encode($this->_text);
51 |
52 | return $this;
53 | }
54 |
55 | /**
56 | * @inheritDoc
57 | */
58 | public function getValue()
59 | {
60 | return $this->_text;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/core/web/jsonld/Thing.php:
--------------------------------------------------------------------------------
1 |
10 | * @since 1.0.3
11 | */
12 | class UrlValue extends BaseValue
13 | {
14 | private $_url;
15 |
16 | /**
17 | * Provide url data.
18 | *
19 | * @param string $url
20 | */
21 | public function __construct($url)
22 | {
23 | $this->_url = $url;
24 | }
25 |
26 | /**
27 | * @inheritDoc
28 | */
29 | public function getValue()
30 | {
31 | return $this->_url;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/dev/luyadev:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | setBaseYiiFile($vendor . '/yiisoft/yii2/Yii.php');
20 | $boot->setConfigArray([
21 | 'id' => 'devenv',
22 | 'basePath' => dirname(__DIR__),
23 | 'enableCoreCommands' => false,
24 | 'aliases' => [
25 | 'appFolder' => getcwd(),
26 | ],
27 | 'defaultRoute' => 'repo',
28 | 'controllerMap' => [
29 | 'repo' => 'luya\dev\RepoController',
30 | 'translation' => 'luya\dev\TranslationController',
31 | ],
32 | ]);
33 | $boot->applicationConsole();
--------------------------------------------------------------------------------
/docs/images/admin-notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/admin-notifications.png
--------------------------------------------------------------------------------
/docs/images/admin-requests.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/admin-requests.png
--------------------------------------------------------------------------------
/docs/images/admin-scheduler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/admin-scheduler.png
--------------------------------------------------------------------------------
/docs/images/admin-tags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/admin-tags.png
--------------------------------------------------------------------------------
/docs/images/cms.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/cms.png
--------------------------------------------------------------------------------
/docs/images/crop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/crop.png
--------------------------------------------------------------------------------
/docs/images/dashboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/dashboard.png
--------------------------------------------------------------------------------
/docs/images/i18n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/images/i18n.png
--------------------------------------------------------------------------------
/docs/logo/LUYA_logo_colors.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/logo/LUYA_logo_colors.pdf
--------------------------------------------------------------------------------
/docs/logo/luya-logo-0.2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/logo/luya-logo-0.2x.png
--------------------------------------------------------------------------------
/docs/logo/luya-logo-0.5x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/logo/luya-logo-0.5x.png
--------------------------------------------------------------------------------
/docs/logo/luya-logo-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/logo/luya-logo-2x.png
--------------------------------------------------------------------------------
/docs/logo/luya-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/logo/luya-logo.png
--------------------------------------------------------------------------------
/docs/misc/security_overview.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luyadev/luya/7960f23c71534fac4b24d85083631b2d91ae8c9a/docs/misc/security_overview.pdf
--------------------------------------------------------------------------------
/docs/releases/note_beta8.md:
--------------------------------------------------------------------------------
1 | Today (11. August 2016) beta 8 of the Yii2-based content management system LUYA was released after several weeks' work! The new version provides many important additions and improvements, including:
2 |
3 | - page permissions allow to restrict the pages a group of backend users can edit (permissions can be granted for individual pages as well as sections)
4 | - status data can now be stored in user settings, like the collapsing of the page tree or the last location in the file manager (which are now remembered by LUYA)
5 | - content blocks can be marked as favorites to be available at the top of the catalogue
6 | - additional block info is available in views, answering questions like "Is this the first block in a container?" or "Is this block preceded or followed by a block of the same type?" (e.g. to open and close wrappers around a group of the same types of blocks)
7 | - the select plugin now uses the "Chosen" jQuery plugin to make selection with long lists more comfortable (https://harvesthq.github.io/chosen/)
8 | - PHP views can now be used as an alternative to Twig views
9 | - dates can now be set using a date picker
10 | - there are new shortcodes for the tag parser to include relative URLs and mail links in Markdown text (e.g. mail[info@luya.io])
11 | - new ngrest sorting and grouping configuration options are available
12 | - page properties can now be accessed through the menu for all pages, not only the current one
13 | - silent modules (interactive=0) allow the automated setup of LUYA installations
14 | - many smaller usability improvements were done
15 | - API documentation is linked with source code on GitHub
16 | - there's additional PHP inline documentation
17 | - the guide was improved and amended
18 |
19 | ### These are some of our plans for the future:
20 |
21 | - new Kickstarter and demo theme
22 | - a complete overhaul of the administration based on Angular 2 and Bootstrap 4
23 |
24 | And, the most important thing of all, a new LUYA logo will be unveiled soon. ;-)
25 |
26 | ### Links
27 |
28 | + [How to Install](https://luya.io/guide/install)
29 | + [How to upgrade existing LUYA Version](https://luya.io/guide/install-upgrade)
30 |
--------------------------------------------------------------------------------
/docs/releases/note_rc1.md:
--------------------------------------------------------------------------------
1 | We are proud to announce the first release candidate (1.0.0-RC1) of LUYA after weeks of intensive work. These are the most significant changes and additions:
2 |
3 | + The administration is loading at least twice as fast as before
4 | + Composer update has been speed up significantly by removing old dependencies (including bower dependencies)
5 | + Core classes and modules have been reorganized to optimize system architecture
6 | + Configuration file naming has been changed to improve clarity
7 | + cms, news and crawler modules now combine admin and frontend submodules so that only one composer package is required
8 | + Introduced tag mechanism to allow for special codes in text fields that are parsed and replaced with any thinkable type of content
9 | + Introduced block injectors that inject related and preprocessed data into a CMS block (the link inspector, as an example, can provide an URL based on a link value stored within a block)
10 | + Introduced the Lazyload widget that loads images only when they scroll into view
11 | + CMS pages can now be copied with their content blocks and languages
12 | + Textareas do now automatically resize vertically according to their content
13 | + NgRest Crud lists automatically activate pagination when there are more than 250 rows (this behavior can be configured)
14 | + Search results can be grouped by content type (this is configured adding CRAWL_GROUP meta information to the source code)
15 | + Tons of bug fixes and small improvements
16 |
17 | > Attention: If you want to upgrade to the first release candidate, there are a few breaking changes you have to take care of. With these changes done, we now have a stable and reliable foundation for the upcoming release candidates and the final release.
18 |
19 | Please check the full [Changelog](https://github.com/luyadev/luya/blob/master/CHANGELOG.md) and the [Upgrading](https://luya.io/guide/install-upgrade) Guide.
20 |
21 | If you have any problems or questions regarding the upgrade process, don't hesitate to contact us on [Gitter](https://gitter.im/luyadev/luya) or to create an [Issue on GitHub](https://github.com/luyadev/luya/issues).
22 |
23 | 4 October 2016
24 | LUYA developer team
25 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "luya",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "repository": "git@github.com:luyadev/luya.git",
6 | "author": "Marc Stampfli ",
7 | "license": "MIT",
8 | "devDependencies": {
9 | "jasmine": "^3.5.0",
10 | "karma": "^6.3.16",
11 | "karma-chrome-launcher": "^3.1.0",
12 | "karma-firefox-launcher": "^1.2.0",
13 | "karma-jasmine": "^2.0.1",
14 | "karma-jasmine-jquery": "^0.1.1",
15 | "karma-phantomjs-launcher": "^1.0.4",
16 | "karma-safari-launcher": "^1.0.0"
17 | },
18 | "scripts": {
19 | "test": "karma start actions.karma.conf.js",
20 | "dev": "karma start karma.conf.js"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/phpstan.neon:
--------------------------------------------------------------------------------
1 | parameters:
2 | level: 0
3 | paths:
4 | - core
5 | excludePaths:
6 | - core/vendor
7 | scanFiles:
8 | - vendor/yiisoft/yii2/Yii.php
9 | bootstrapFiles:
10 | - vendor/yiisoft/yii2/Yii.php
11 | tmpDir: .tmp
--------------------------------------------------------------------------------
/rector.php:
--------------------------------------------------------------------------------
1 | paths([
11 | __DIR__ . '/core'
12 | ]);
13 |
14 | $rectorConfig->skip([
15 | __DIR__ . '/core/vendor',
16 | ]);
17 |
18 | // register a single rule
19 | $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
20 |
21 | // define sets of rules
22 | $rectorConfig->sets([
23 | LevelSetList::UP_TO_PHP_70
24 | ]);
25 | };
26 |
--------------------------------------------------------------------------------
/scripts/.gitignore:
--------------------------------------------------------------------------------
1 | /.subsplit/
2 |
--------------------------------------------------------------------------------
/scripts/gource.sh:
--------------------------------------------------------------------------------
1 | gource --hide filenames,mouse,date,progress --camera-mode track --seconds-per-day 0.5 --auto-skip-seconds 0.2 --title "LUYA.io" --max-file-lag 0.1 -1280x720 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4
--------------------------------------------------------------------------------
/scripts/rebasemaster.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # When running the rebasemaster on the first time, use the init command.
4 |
5 | if [ "$1" = "init" ]; then
6 | git remote add upstream https://github.com/luyadev/luya.git
7 | fi
8 |
9 | # simply type ./scripts/rebasemaster.sh branch **your-branch-name** in terminal
10 |
11 | BRANCH="master"
12 |
13 | if [ "$1" = "branch" ]; then
14 | BRANCH=$2
15 | fi
16 |
17 | git checkout $BRANCH
18 | git fetch upstream
19 | git rebase upstream/$BRANCH $BRANCH
20 |
--------------------------------------------------------------------------------
/scripts/subsplit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # apt-get install svn
3 | # wget https://github.com/dflydev/git-subsplit/archive/master.zip
4 |
5 | REPO="git@github.com:luyadev/luya"
6 | BASE="git@github.com:luyadev"
7 |
8 | if [ "$1" = "init" ]; then
9 | git subsplit init $REPO
10 | else
11 | git subsplit update
12 | fi
13 |
14 | git subsplit publish "
15 | core:$BASE/luya-core.git
16 | " --heads=master -q
17 |
--------------------------------------------------------------------------------
/tests/LuyaConsoleTestCase.php:
--------------------------------------------------------------------------------
1 | applicationWeb();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/LuyaWebTestCase.php:
--------------------------------------------------------------------------------
1 | applicationWeb();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/README.md:
--------------------------------------------------------------------------------
1 | TESTS
2 | =====
3 |
4 |
5 | Database Setup for Unittests.
6 |
7 | Login: test@luya.io
8 | Password: testluyaio
9 |
10 |
11 | Additional structure to luya kickstarter
12 | -----
13 |
14 | ```
15 | --
16 | -- Table structure for table `dummy_table`
17 | --
18 |
19 | CREATE TABLE IF NOT EXISTS `dummy_table` (
20 | `id` int(11) NOT NULL,
21 | `i18n_text` text NOT NULL,
22 | `i18n_textarea` text NOT NULL,
23 | `date` int(11) NOT NULL,
24 | `datetime` int(11) NOT NULL,
25 | `file_array` text NOT NULL,
26 | `image_array` text NOT NULL,
27 | `select` int(11) NOT NULL,
28 | `cms_page` int(11) NOT NULL
29 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
30 |
31 | --
32 | -- Indexes for dumped tables
33 | --
34 |
35 | --
36 | -- Indexes for table `dummy_table`
37 | --
38 | ALTER TABLE `dummy_table`
39 | ADD PRIMARY KEY (`id`);
40 |
41 | --
42 | -- AUTO_INCREMENT for dumped tables
43 | --
44 |
45 | --
46 | -- AUTO_INCREMENT for table `dummy_table`
47 | --
48 | ALTER TABLE `dummy_table`
49 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
50 | ```
--------------------------------------------------------------------------------
/tests/core/ExceptionTest.php:
--------------------------------------------------------------------------------
1 | expectException('\luya\Exception');
10 | throw new \luya\Exception('fixme');
11 | }
12 |
13 | public function testNameException()
14 | {
15 | $e = new \luya\Exception('fixme');
16 | $this->assertEquals('LUYA Exception', $e->getName());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tests/core/base/BaseBootstrapTest.php:
--------------------------------------------------------------------------------
1 | bootstrap(Yii::$app);
26 | $this->assertTrue($bs->hasModule('unitmodule'));
27 | $this->assertFalse($bs->hasModule('notexistingmodule'));
28 | }
29 |
30 | public function testEmptyModules()
31 | {
32 | $app = new Application(['id' => '123', 'basePath' => '']);
33 | $boot = new CustomBootstrap();
34 | $boot->bootstrap($app);
35 | $this->assertSame([], $boot->getModules());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tests/core/base/DynamicModelTest.php:
--------------------------------------------------------------------------------
1 | attributeLabels = [
18 | 'foo' => 'Foo Label',
19 | 'bar' => 'Bar Label',
20 | ];
21 |
22 | $atr = $model->attributeLabels();
23 |
24 | $this->assertArrayHasKey('foo', $atr);
25 | $this->assertArrayHasKey('bar', $atr);
26 | $this->assertSame('Foo Label', $atr['foo']);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/core/base/PackageInstallerTest.php:
--------------------------------------------------------------------------------
1 | 12345,
14 | 'configs' => [
15 | 'luyadev/luya-module-admin' => [
16 | 'package' => [
17 | 'foobar' => 'barfoo',
18 | ],
19 | 'nonexstingstring' => 'content',
20 | 'nonexistingarray' => ['content1', 'content2'],
21 | 'blocks' => ['block.php'],
22 | 'bootstrap' => ['bootstrap.php'],
23 | ]
24 | ]
25 | ]);
26 |
27 | foreach ($installer->getConfigs() as $config) {
28 | $this->assertSame(['foobar' => 'barfoo'], $config->package);
29 | $this->assertSame('content', $config->getValue('nonexstingstring'));
30 | $this->assertSame(null, $config->getValue('THIS_KEY_DOES_NOT_EXISTS'));
31 | $this->assertSame(['content1', 'content2'], $config->getValue('nonexistingarray'));
32 | $this->assertSame(['block.php'], $config->blocks);
33 | $this->assertSame(['bootstrap.php'], $config->bootstrap);
34 |
35 | $this->expectException('yii\base\UnknownPropertyException');
36 | $config->doesnotexsts;
37 | }
38 |
39 | $this->assertSame(12345, $installer->getTimestamp());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/tests/core/base/WidgetTest.php:
--------------------------------------------------------------------------------
1 | assertStringContainsString('core/base/views', (new Widget())->getViewPath());
13 | }
14 |
15 | public function testUseAppViewsPath()
16 | {
17 | $this->assertStringContainsString('@app/views/widgets', (new Widget(['useAppViewPath' => true]))->getViewPath());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/core/behaviors/TimestampTest.php:
--------------------------------------------------------------------------------
1 | sender = new DummyBaseModel();
16 |
17 | $behavior = new Timestamp();
18 | $behavior->insert = ['foo'];
19 | $behavior->beforeInsert($event);
20 |
21 | $this->assertNotNull($event->sender->foo);
22 | $this->assertNull($event->sender->bar);
23 | }
24 |
25 | public function testUpdateEvent()
26 | {
27 | $event = new ModelEvent();
28 | $event->sender = new DummyBaseModel();
29 |
30 | $behavior = new Timestamp();
31 | $behavior->update = ['foo'];
32 | $behavior->beforeUpdate($event);
33 |
34 | $this->assertNotNull($event->sender->foo);
35 | $this->assertNull($event->sender->bar);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tests/core/components/FormatterTest.php:
--------------------------------------------------------------------------------
1 | [
16 | 'en' => 'MM/MM/MM',
17 | 'de' => 'YYYY/YYYY/YYYY',
18 | ],
19 | 'locale' => 'de',
20 | ]);
21 |
22 | // only with php intl extension the response will be like this!
23 | $this->assertSame('2017/2017/2017', $formatter->asDate($ts));
24 |
25 | $formatter = new Formatter([
26 | 'datetimeFormats' => [
27 | 'en' => 'HH/mm',
28 | 'de' => 'HH:mm',
29 | 'fr' => 'HH.mm',
30 | ],
31 | 'locale' => 'fr',
32 | ]);
33 |
34 | $this->assertSame('14.00', $formatter->asDatetime($ts));
35 |
36 | $formatter = new Formatter([
37 | 'timeFormats' => [
38 | 'en' => 'HH/mm/ss',
39 | 'de' => 'mm/HH/ss',
40 | 'fr' => 'HH:mm:ss',
41 | ],
42 | 'locale' => 'fr',
43 | ]);
44 |
45 | $this->assertSame('14:00:33', $formatter->asTime($ts));
46 | }
47 |
48 | public function testautoFormat()
49 | {
50 | $formatter = new Formatter();
51 |
52 | $this->assertSame(1, $formatter->autoFormat(1));
53 | $this->assertSame('Yes', $formatter->autoFormat(true));
54 | $this->assertSame('No', $formatter->autoFormat(false));
55 | $this->assertSame('demo@luya.io', $formatter->autoFormat('demo@luya.io'));
56 | $this->assertSame('https://luya.io', $formatter->autoFormat('https://luya.io'));
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/tests/core/console/ApplicationTest.php:
--------------------------------------------------------------------------------
1 | expectException('yii\console\Exception');
16 | $this->app->runAction('luya/luya/luya');
17 | }
18 |
19 | public function testInvalidRouteCommand()
20 | {
21 | $this->expectException('yii\console\UnknownCommandException');
22 | $this->app->runAction('consolemodule/test-command/notavailable');
23 | }
24 |
25 | public function testInvalidApplicationContext()
26 | {
27 | $module = new Application(['basePath' => dirname(__DIR__), 'id' => 'barfoo']);
28 | $this->expectException("yii\base\InvalidCallException");
29 | $command = new TestConsoleCommand('console', $module);
30 | $command->actionFoo();
31 | }
32 |
33 | public function testRouting()
34 | {
35 | $this->assertSame(Controller::EXIT_CODE_NORMAL, Yii::$app->runAction('consolemodule/test-command/success'));
36 | $this->assertSame(Controller::EXIT_CODE_ERROR, Yii::$app->runAction('consolemodule/test-command/error'));
37 | $this->assertSame(Controller::EXIT_CODE_NORMAL, Yii::$app->runAction('consolemodule/test-command/info'));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tests/core/console/CommandTest.php:
--------------------------------------------------------------------------------
1 | getModule('unitmodule'));
20 |
21 | $className = $cmd->createClassName('das-ist-mein', 'mein0r');
22 |
23 | $this->assertEquals('FooActiveWindow', $cmd->createClassName('FooActiveWindow', 'ActiveWindow'));
24 | $this->assertEquals('FooActiveWindow', $cmd->createClassName('foo-active-window', 'ActiveWindow'));
25 | $this->assertEquals('FooActiveWindow', $cmd->createClassName('foo', 'ActiveWindow'));
26 | }
27 |
28 | public function testHelper()
29 | {
30 | $cmd = new SubCommand('myid', Yii::$app->getModule('unitmodule'));
31 | $help = $cmd->getHelp();
32 | $this->assertSame('', $help);
33 | }
34 |
35 | public function testPrintableDebugMessage()
36 | {
37 | $cmd = new SubCommand('myid', Yii::$app->getModule('unitmodule'));
38 | $this->assertSame('foobar', $cmd->printableMessage('foobar'));
39 | $this->assertSameTrimmed('array (
40 | \'foo\' => \'bar\',
41 | )', $cmd->printableMessage(['foo' => 'bar']));
42 |
43 | $cmd->verbose = 1;
44 | $cmd->verbosePrint('verbose!');
45 |
46 | $this->app->mute = 0;
47 |
48 | $this->assertSame(1, $cmd->outputError('test'));
49 | $this->assertSame(0, $cmd->outputSuccess(['foo' => 'bar']));
50 | $this->assertSame(0, $cmd->outputInfo('info'));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/tests/core/console/ControllerTest.php:
--------------------------------------------------------------------------------
1 | assertEquals(0, $obj->outputInfo('info'));
19 | $this->assertEquals(0, $obj->outputSuccess('success'));
20 | $this->assertEquals(1, $obj->outputError('error'));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/core/console/ErrorHandlerTest.php:
--------------------------------------------------------------------------------
1 | transferException = true;
16 | ob_start();
17 | $handler->renderException($error);
18 | $output = ob_get_clean();
19 |
20 | $this->assertNotNull($handler->lastTransferCall);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/core/console/ImporterTest.php:
--------------------------------------------------------------------------------
1 | importer->id;
15 | }
16 |
17 | public function getTestModuleId()
18 | {
19 | return $this->module->id;
20 | }
21 | }
22 |
23 | class ImporterTest extends LuyaConsoleTestCase
24 | {
25 | public function testInstance()
26 | {
27 | $importRunner = new ImportController('import-runner', Yii::$app);
28 |
29 | $import = new StubImporter($importRunner, Yii::$app->getModule('unitmodule'));
30 | $this->assertSame('import-runner', $import->run());
31 | $this->assertSame('unitmodule', $import->getTestModuleId());
32 |
33 | $import->addLog('value');
34 |
35 | $this->assertArrayHasKey('luyatests\core\console\StubImporter', $importRunner->getLog());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tests/core/console/commands/HealthControllerTest.php:
--------------------------------------------------------------------------------
1 | actionIndex();
15 |
16 | $this->assertEquals("The directory the health commands is applying to: " . realpath(Yii::getAlias('@luyatests/data')), $ctrl->readOutput());
17 | $this->assertEquals("public_html/assets: directory exists already", $ctrl->readOutput());
18 | $this->assertEquals("public_html/storage: successfully created directory", $ctrl->readOutput());
19 | $this->assertEquals("migrations: directory exists already", $ctrl->readOutput());
20 | $this->assertEquals("vendor: directory exists already", $ctrl->readOutput());
21 | $this->assertEquals("runtime: directory exists already", $ctrl->readOutput());
22 | $this->assertEquals("configs/env.php: file does not exists!", $ctrl->readOutput());
23 | $this->assertEquals("public_html/index.php: file does not exists!", $ctrl->readOutput());
24 | $this->assertEquals("Health check found errors!", $ctrl->readOutput());
25 | }
26 | }
27 |
28 | class HealthControllerStub extends HealthController
29 | {
30 | use CommandStdStreamTrait;
31 | }
32 |
--------------------------------------------------------------------------------
/tests/core/console/commands/ImportControllerTest.php:
--------------------------------------------------------------------------------
1 | request->setParams([
14 | 'import/index',
15 | ]);
16 |
17 | $resp = Yii::$app->run();
18 |
19 | $this->assertEquals(0, $resp);
20 | }
21 |
22 | public function testFileScanner()
23 | {
24 | Yii::$app->setModules([
25 | 'importermodule' => ['class' => Module::class],
26 | ]);
27 | Yii::$app->getModule('importermodule'); // re init the bootstrapc process
28 | $ctrl = new ImportController('import-runner', Yii::$app);
29 | $ctrl->actionIndex();
30 |
31 | $files = $ctrl->getDirectoryFiles('blocks');
32 |
33 | $this->assertNotEmpty($files);
34 | $this->assertArrayHasKey(0, $files);
35 |
36 | $this->assertSame('ImportTestFile.php', $files[0]['file']);
37 | }
38 |
39 | public function testImporterQueue()
40 | {
41 | Yii::$app->setModules([
42 | 'importermodule' => ['class' => Module::class],
43 | ]);
44 | Yii::$app->getModule('importermodule'); // re init the bootstrapc process
45 | $ctrl = new ImportController('import-runner', Yii::$app);
46 | $this->assertEmpty($ctrl->buildImporterQueue());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/tests/core/console/commands/RunCommandsTest.php:
--------------------------------------------------------------------------------
1 | request->setParams([
12 | 'unitmodule/command-output/success',
13 | ]);
14 |
15 | $this->assertEquals(0, Yii::$app->run());
16 | }
17 |
18 | public function testCustomCommandError()
19 | {
20 | Yii::$app->request->setParams([
21 | 'unitmodule/command-output/error',
22 | ]);
23 |
24 | $this->assertEquals(1, Yii::$app->run());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/core/rest/ActiveControllerTest.php:
--------------------------------------------------------------------------------
1 | assertArrayHasKey('index', $ctrl->actions());
21 | $this->assertSame('yii\rest\IndexAction', $ctrl->actions()['index']['class']);
22 | $this->assertArrayHasKey('delete', $ctrl->actions());
23 | $this->assertSame('yii\rest\DeleteAction', $ctrl->actions()['delete']['class']);
24 | }
25 |
26 | public function testActionCheckAccessNullify()
27 | {
28 | $ctrl = new StubActiveController('stub', Yii::$app);
29 | $this->assertEmpty($ctrl->checkAccess('index'));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tests/core/rest/ControllerTest.php:
--------------------------------------------------------------------------------
1 | expectException('yii\base\InvalidParamException');
33 | $ctrl->sendModelError($model);
34 | }
35 |
36 | public function testSendModelError()
37 | {
38 | $ctrl = new Controller('test', Yii::$app);
39 |
40 | $model = new FooModel();
41 | $model->validate();
42 |
43 | $response = $ctrl->sendModelError($model);
44 |
45 | $this->assertSame(2, count($response));
46 | $this->arrayHasKey('field', $response[0]);
47 | $this->assertSame('firstname', $response[0]['field']);
48 | $this->arrayHasKey('message', $response[0]);
49 | }
50 |
51 | public function testSendArrayError()
52 | {
53 | $ctrl = new Controller('test', Yii::$app);
54 |
55 | $this->assertSame([
56 | ['field' => 'field1', 'message' => 'message1'],
57 | ['field' => 'field2', 'message' => 'message2a'],
58 | ['field' => 'field2', 'message' => 'message2b'],
59 | ], $ctrl->sendArrayError([
60 | 'field1' => 'message1',
61 | 'field2' => ['message2a', 'message2b'],
62 | ]));
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/tests/core/tag/BaseTagTest.php:
--------------------------------------------------------------------------------
1 | assertInstanceOf('luya\web\View', $mock->getView());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tests/core/tag/tags/MailTagTest.php:
--------------------------------------------------------------------------------
1 | assertNotNull($tag->readme());
15 | $this->assertNotNull($tag->readme());
16 |
17 | $this->assertSame('hello@luya.io', $tag->parse('hello@luya.io', null));
18 | $this->assertSame('E-Mail', $tag->parse('hello@luya.io', 'E-Mail'));
19 |
20 | $tag->obfuscate = false;
21 |
22 | $this->assertSame('foo@luya.io', $tag->parse('foo@luya.io', null));
23 | $this->assertSame('text', $tag->parse('foo@luya.io', 'text'));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/core/tag/tags/TelTagTest.php:
--------------------------------------------------------------------------------
1 | assertSame('+123', $tag->parse('+123', null));
14 | $this->assertSame('123', $tag->parse('123', null));
15 | $this->assertSame('call', $tag->parse('+123', 'call'));
16 | $this->assertNotNull($tag->readme());
17 | $this->assertNotNull($tag->example());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/core/texttospeech/TextToSpeechWidgetTest.php:
--------------------------------------------------------------------------------
1 | '#foobar'
14 | ]);
15 |
16 | $this->assertContainsNoSpace('
17 |