repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/modules/datecontrol/Module.php
src/modules/datecontrol/Module.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.09.2015 */ namespace skeeks\cms\modules\datecontrol; /** * Class Module * @package skeeks\cms\modules\datecontrol */ class Module extends \kartik\datecontrol\Module { public $controllerNamespace = 'kartik\datecontrol\controllers'; public $displaySettings = [ \kartik\datecontrol\Module::FORMAT_DATE => 'dd-MM-yyyy', \kartik\datecontrol\Module::FORMAT_TIME => 'HH:mm:ss', \kartik\datecontrol\Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss', ]; // format settings for saving each date attribute (PHP format example) public $saveSettings = [ \kartik\datecontrol\Module::FORMAT_DATE => 'php:U', // saves as unix timestamp \kartik\datecontrol\Module::FORMAT_TIME => 'php:U', //'php:H:i:s', \kartik\datecontrol\Module::FORMAT_DATETIME => 'php:U', //'php:Y-m-d H:i:s', ]; // set your display timezone public $displayTimezone = 'Europe/Moscow'; // set your timezone for date saved to db public $saveTimezone = 'UTC'; // automatically use kartik\widgets for each of the above formats public $autoWidget = true; // use ajax conversion for processing dates from display format to save format. public $ajaxConversion = true; // default settings for each widget from kartik\widgets used when autoWidget is true public $autoWidgetSettings = [ \kartik\datecontrol\Module::FORMAT_DATE => [ 'pluginOptions' => [ 'autoclose' => true, 'todayBtn' => true, ], ], // example \kartik\datecontrol\Module::FORMAT_DATETIME => [ 'pluginOptions' => [ 'autoclose' => true, 'todayBtn' => true, ], ], // setup if needed \kartik\datecontrol\Module::FORMAT_TIME => [], // setup if needed ]; // custom widget settings that will be used to render the date input instead of kartik\widgets, // this will be used when autoWidget is set to false at module or widget level. public $widgetSettings = [ \kartik\datecontrol\Module::FORMAT_DATE => [ //'class' => '\yii\jui\DatePicker', // example 'class' => '\kartik\datetime\DatePicker', 'options' => [ 'dateFormat' => 'php:d-M-Y', 'options' => ['class' => 'form-control'], ], ], \kartik\datecontrol\Module::FORMAT_DATETIME => [ 'class' => '\kartik\datetime\DateTimePicker', 'options' => [ 'dateFormat' => 'php:d-F-Y H:i:s', 'options' => ['class' => 'form-control'], ], ], ]; // other settings }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/mail-templates/auth-by-email-code.php
src/mail-templates/auth-by-email-code.php
<?php use skeeks\cms\mail\helpers\Html; /* @var $this yii\web\View */ /* @var $code */ ?> <p> Ваш код подтверждения: </p> <p> <b><?php echo $code; ?></b> </p> <p> Наберите его в поле ввода. </p>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/mail-templates/password-reset-token.php
src/mail-templates/password-reset-token.php
<?php use skeeks\cms\mail\helpers\Html; /* @var $this yii\web\View */ /* @var $user common\models\User */ /* @var $resetLink */ if (!$resetLink) { $resetLink = \skeeks\cms\helpers\UrlHelper::construct('/admin/auth/reset-password', ['token' => $user->password_reset_token])->enableAbsolute()->enableAdmin(); } ?> <?/*= Html::beginTag('h1'); */?><!-- Напоминание пароля на <?/*= \Yii::$app->cms->appName */?> --><?/*= Html::endTag('h1'); */?> <?= Html::beginTag('p'); ?> Здравствуйте! <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Мы получили запрос на восстановление пароля для <?= $user->email; ?> для сайта <?= Html::a(\Yii::$app->name, \yii\helpers\Url::home(true)); ?>. <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Если Вы хотите восстановить пароль, кликните по ссылке: <?= Html::a($resetLink, $resetLink) ?> <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Если Вы НЕ запрашивали восстановление пароля, просто проигнорируйте это письмо. <?= Html::endTag('p'); ?>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/mail-templates/register-by-email.php
src/mail-templates/register-by-email.php
<?php use skeeks\cms\mail\helpers\Html; /* @var $this yii\web\View */ /* @var $user common\models\User */ /* @var $resetLink */ ?> <?/*= Html::beginTag('h1'); */?><!-- Регистрация на сайте <?/*= \Yii::$app->cms->appName */?> --><?/*= Html::endTag('h1'); */?> <?= Html::beginTag('p'); ?> Здравствуйте!<br><br>Вы успешно зарегистрированны на сайте <?= Html::a(\Yii::$app->name, \yii\helpers\Url::home(true)) ?>.<br> <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Для авторизации на сайте используйте следующие данные: <br> <br> <b>Email: </b><?= $user->email; ?><br> <b>Пароль: </b><?= $password; ?><br> <br> <?= Html::a("Войти в кабинет", \skeeks\cms\helpers\UrlHelper::construct('/cms/auth/login') /*->setRef( \skeeks\cms\helpers\UrlHelper::construct('/cms/profile')->enableAbsolute()->toString() )*/ ->enableAbsolute() ->toString() ) ?> <?= Html::endTag('p'); ?>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/mail-templates/checker.php
src/mail-templates/checker.php
<?php use skeeks\cms\mail\helpers\Html; /* @var $this yii\web\View */ /* @var $user common\models\User */ /* @var $resetLink */ ?> <?= Html::beginTag('h1'); ?> Тестирование отправки писем с сайта <?= \Yii::$app->cms->appName ?> <?= Html::endTag('h1'); ?> <?= Html::beginTag('p'); ?> Здравствуйте!<br><br>Отправка произведена с сайта <?= Html::a(\Yii::$app->name, \yii\helpers\Url::home(true)) ?>.<br> Это письмо можно просто удалить. <?= Html::endTag('p'); ?>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/mail-templates/new-password.php
src/mail-templates/new-password.php
<?php use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $user common\models\User */ ?> <?= Html::beginTag('p'); ?> Здравствуйте! <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Используйте новый пароль для авторизации на сайте <?= Html::a(\Yii::$app->cms->appName, \yii\helpers\Url::home(true)) ?>: <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> <b><?= $password ?></b> <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> При необходимости Вы сможете изменить его в личном Кабинете. <?= Html::endTag('p'); ?>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/mail-templates/approve-email.php
src/mail-templates/approve-email.php
<?php use skeeks\cms\mail\helpers\Html; /* @var $this yii\web\View */ /* @var $resetLink */ ?> <?= Html::beginTag('p'); ?> Здравствуйте! <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Вы успешно зарегистрированны. <?= Html::endTag('p'); ?> <?= Html::beginTag('p'); ?> Для аткивации вашей учетной записи перейдите по ссылке: <?= $approveUrl; ?> <?= Html::endTag('p'); ?>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/rbac/CmsCompanyRule.php
src/rbac/CmsCompanyRule.php
<?php /** * AuthorRule * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 21.11.2014 * @since 1.0.0 */ namespace skeeks\cms\rbac; use skeeks\cms\models\CmsCompany; use skeeks\cms\models\CmsUser; use skeeks\cms\rbac\Item; use yii\rbac\Rule; /** * Checks if authorID matches user passed via params */ class CmsCompanyRule extends Rule { const NAME = 'CmsCompanyRule'; public $name = self::NAME; /** * @param string|integer $user the user ID. * @param Item $item the role or permission that this rule is associated with * @param array $params parameters passed to ManagerInterface::checkAccess(). * @return boolean a value indicating whether the rule permits the role or permission it is associated with. */ public function execute($user, $item, $params) { if (isset($params['model'])) { /** * Пользователь доступ к которому проверяем * @var CmsUser $currentUser * @var CmsUser $model */ $model = $params['model']; $currentUser = CmsUser::findOne($user); //Если пользователь является подчиненным для текущего, то его можно редактировать /*if ($currentUser->getSubordinates()->andWhere(['id' => $model->id])->exists()) { return true; }*/ //Если пользователь доступен для текущего if (CmsCompany::find() ->forManager($currentUser) //Поиск пользователей доступных текущему пользователю ->andWhere([CmsCompany::tableName().'.id' => $model->id]) //Пользователь которого проверяем ->exists()) { return true; } } return false; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/rbac/CmsTaskRule.php
src/rbac/CmsTaskRule.php
<?php /** * AuthorRule * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 21.11.2014 * @since 1.0.0 */ namespace skeeks\cms\rbac; use skeeks\cms\models\CmsLog; use skeeks\cms\models\CmsTask; use skeeks\cms\models\CmsUser; use skeeks\cms\rbac\Item; use yii\rbac\Rule; /** * Checks if authorID matches user passed via params */ class CmsTaskRule extends Rule { const NAME = 'CmsTaskRule'; public $name = self::NAME; /** * @param string|integer $user the user ID. * @param Item $item the role or permission that this rule is associated with * @param array $params parameters passed to ManagerInterface::checkAccess(). * @return boolean a value indicating whether the rule permits the role or permission it is associated with. */ public function execute($user, $item, $params) { if (isset($params['model'])) { /** * Пользователь доступ к которому проверяем * @var CmsUser $currentUser * @var CmsUser $model */ $model = $params['model']; $currentUser = CmsUser::findOne($user); //Если пользователь является подчиненным для текущего, то его можно редактировать /*if ($currentUser->getSubordinates()->andWhere(['id' => $model->id])->exists()) { return true; }*/ //Если пользователь доступен для текущего if (CmsTask::find() ->forManager($currentUser) //Поиск пользователей доступных текущему пользователю ->andWhere([CmsTask::tableName() . '.id' => $model->id]) //Пользователь которого проверяем ->exists() ) { return true; } } return false; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/rbac/CmsUserRule.php
src/rbac/CmsUserRule.php
<?php /** * AuthorRule * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 21.11.2014 * @since 1.0.0 */ namespace skeeks\cms\rbac; use skeeks\cms\models\CmsLog; use skeeks\cms\models\CmsUser; use skeeks\cms\rbac\Item; use yii\rbac\Rule; /** * Checks if authorID matches user passed via params */ class CmsUserRule extends Rule { const NAME = 'cmsUserRule'; public $name = self::NAME; /** * @param string|integer $user the user ID. * @param Item $item the role or permission that this rule is associated with * @param array $params parameters passed to ManagerInterface::checkAccess(). * @return boolean a value indicating whether the rule permits the role or permission it is associated with. */ public function execute($user, $item, $params) { if (isset($params['model'])) { /** * Пользователь доступ к которому проверяем * @var CmsUser $currentUser * @var CmsUser $model */ $model = $params['model']; $currentUser = CmsUser::findOne($user); //Если пользователь является подчиненным для текущего, то его можно редактировать if ($currentUser->getSubordinates()->andWhere(['id' => $model->id])->exists()) { return true; } //Если пользователь доступен для текущего if (CmsUser::find() ->forManager($currentUser) //Поиск пользователей доступных текущему пользователю ->andWhere([CmsUser::tableName() . '.id' => $model->id]) //Пользователь которого проверяем ->exists() ) { return true; } } return false; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/rbac/CmsLogRule.php
src/rbac/CmsLogRule.php
<?php /** * AuthorRule * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 21.11.2014 * @since 1.0.0 */ namespace skeeks\cms\rbac; use skeeks\cms\models\CmsLog; use skeeks\cms\rbac\Item; use yii\rbac\Rule; /** * Checks if authorID matches user passed via params */ class CmsLogRule extends Rule { const NAME = 'cmsLogRule'; public $name = self::NAME; /** * @param string|integer $user the user ID. * @param Item $item the role or permission that this rule is associated with * @param array $params parameters passed to ManagerInterface::checkAccess(). * @return boolean a value indicating whether the rule permits the role or permission it is associated with. */ public function execute($user, $item, $params) { if (isset($params['model']) && isset($params['model']->created_by)) { /** * @var CmsLog $model */ $model = $params['model']; //Если пользователь является автором комментария if ($model->created_by == $user) { //Только комментарий if ($model->log_type == CmsLog::LOG_TYPE_COMMENT) { //Если с момента написания комментария прошло менее 24 часов if (time() - $params['model']->created_at < 60*60*24) { return true; } } } } return false; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/rbac/CmsWorkerRule.php
src/rbac/CmsWorkerRule.php
<?php /** * AuthorRule * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 21.11.2014 * @since 1.0.0 */ namespace skeeks\cms\rbac; use skeeks\cms\models\CmsLog; use skeeks\cms\models\CmsUser; use skeeks\cms\rbac\Item; use yii\rbac\Rule; /** * Checks if authorID matches user passed via params */ class CmsWorkerRule extends Rule { const NAME = 'cmsWorkerRule'; public $name = self::NAME; /** * @param string|integer $user the user ID. * @param Item $item the role or permission that this rule is associated with * @param array $params parameters passed to ManagerInterface::checkAccess(). * @return boolean a value indicating whether the rule permits the role or permission it is associated with. */ public function execute($user, $item, $params) { if (isset($params['model'])) { /** * Пользователь доступ к которому проверяем * @var CmsUser $currentUser * @var CmsUser $model */ $model = $params['model']; $currentUser = CmsUser::findOne($user); //Если пользователь является подчиненным для текущего, то его можно редактировать if ($currentUser->getSubordinates()->andWhere(['id' => $model->id])->exists()) { //Только комментарий return true; } } return false; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/config/web.php
src/config/web.php
<?php /** * Самый базовый конфиг приложения на базе skeeks cms * По умолчанию конфигурирование всех базовых используемых компонентов и админки * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 31.10.2014 * @since 1.0.0 */ $config = [ 'bootstrap' => ['cms', 'upaBackend'], 'components' => [ 'adult' => [ 'class' => \skeeks\cms\components\Adult::class, ], 'errorHandler' => [ 'errorAction' => 'cms/error/error', ], 'user' => [ 'class' => '\yii\web\User', 'identityClass' => 'skeeks\cms\models\CmsUser', 'enableAutoLogin' => true, 'loginUrl' => ['cms/auth/login'], ], 'session' => [ //Чтобы не разрушался сеанс сессии, после закрытия браузера нужно уставить cookie 'timeout' => 3600 * 24 * 365, 'useCookies' => true, 'cookieParams' => [ 'httponly' => true, 'lifetime' => 3600 * 24 * 365, ], ], 'assetManager' => [ 'appendTimestamp' => true, 'bundles' => [ 'yii\web\JqueryAsset' => [ 'js' => [ 'jquery.min.js', ], ], 'yii\bootstrap\BootstrapPluginAsset' => [ 'js' => [ 'js/bootstrap.min.js', ], ], 'yii\bootstrap\BootstrapAsset' => [ 'css' => [ 'css/bootstrap.min.css', ], ], ], ], 'view' => [ 'class' => '\skeeks\cms\web\View', /*'themes' => [ "id" => [ 'class' => \skeeks\cms\base\Theme::class ], ]*/ ], 'breadcrumbs' => [ 'class' => '\skeeks\cms\components\Breadcrumbs', ], 'upaBackend' => [ 'id' => 'upaBackend', 'class' => \skeeks\cms\components\UpaBackendComponent::class, 'menu' => [ 'data' => [ 'personal' => [ 'name' => ['skeeks/cms', 'Мой профиль'], 'url' => ['/cms/upa-personal/view'], 'icon' => 'icon-user', ], 'profile' => [ 'priority' => 9999, 'name' => 'Личные данные', 'url' => ['/cms/upa-personal/update'], 'items' => [ [ 'name' => 'Личные данные', 'url' => ['/cms/upa-personal/update'], ], [ 'name' => 'Смена пароля', 'url' => ['/cms/upa-personal/password'], ], ], ], ], ], ], ], 'modules' => [ 'datecontrol' => [ 'class' => 'skeeks\cms\modules\datecontrol\Module', ], ], ]; return $config;
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/config/common.php
src/config/common.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright (c) 2010 SkeekS * @date 06.11.2017 */ return [ 'bootstrap' => ['skeeks'], 'vendorPath' => '@vendor', 'aliases' => [ '@bower' => '@vendor/bower-asset', '@npm' => '@vendor/npm-asset', ], 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'cms' => [ 'class' => '\skeeks\cms\components\Cms', ], 'storage' => [ 'class' => 'skeeks\cms\components\Storage', 'components' => [ 'local' => [ 'class' => 'skeeks\cms\components\storage\ClusterLocal', 'priority' => 100, ], ], ], 'skeeks' => [ 'class' => '\skeeks\cms\Skeeks', ], 'legal' => [ 'class' => \skeeks\cms\components\LegalComponent::class, ], 'imaging' => [ 'class' => '\skeeks\cms\components\Imaging', ], 'console' => [ 'class' => 'skeeks\cms\components\ConsoleComponent', ], 'i18n' => [ 'translations' => [ 'skeeks/cms' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@skeeks/cms/messages', 'fileMap' => [ 'skeeks/cms' => 'main.php', ], ], 'skeeks/cms/user' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@skeeks/cms/messages', 'fileMap' => [ 'skeeks/cms/user' => 'user.php', ], ], ], ], 'urlManager' => [ 'class' => 'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'suffix' => '', 'normalizer' => [ 'class' => 'yii\web\UrlNormalizer', 'collapseSlashes' => true, 'normalizeTrailingSlash' => true, 'action' => \yii\web\UrlNormalizer::ACTION_REDIRECT_PERMANENT, ], /*'rules' => [ 'u' => 'cms/user/index', 'u/<username>' => 'cms/user/view', 'u/<username>/<action>' => 'cms/user/<action>', '~<_a:(login|logout|register|forget|reset-password|approve-email)>' => 'cms/auth/<_a>', 'skeeks-cms' => 'cms/cms/index', 'skeeks-cms/<action>' => 'cms/cms/<action>', 'favicon.<extension:\w+>' => '/cms/favicon/on-request', "image-preview" => ["class" => 'skeeks\cms\components\urlRules\UrlRuleImagePreview'], "storage-file" => ["class" => 'skeeks\cms\components\urlRules\UrlRuleStorageFile'], [ 'class' => \skeeks\cms\components\urlRules\UrlRuleSavedFilter::class ], ],*/ ], 'cmsAgent' => [ 'commands' => [ 'cms/cache/flush-all' => [ 'class' => \skeeks\cms\agent\CmsAgent::class, 'name' => ['skeeks/cms', 'Clearing the cache'], 'interval' => 3600 * 24, ], 'ajaxfileupload/cleanup' => [ 'class' => \skeeks\cms\agent\CmsAgent::class, 'name' => ['skeeks/cms', 'Cleaning temporarily downloaded files'], 'interval' => 3600 * 24, ], /*'cms/utils/update-content-element-codes' => [ 'class' => \skeeks\cms\agent\CmsAgent::class, 'name' => ['skeeks/cms', 'Обновляет url для элементов'], 'interval' => 3600 * 24 * 7, ],*/ ], ], 'authManager' => [ 'config' => require __DIR__ . '/_permissions.php' ], ], 'modules' => [ 'cms' => [ 'class' => '\skeeks\cms\Module', ], 'ajaxfileupload' => [ 'class' => '\skeeks\yii2\ajaxfileupload\AjaxFileUploadModule', ], ], ];
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/config/console.php
src/config/console.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright (c) 2010 SkeekS * @date 10.11.2017 */ $config = [ 'modules' => [ 'cms' => [ 'controllerNamespace' => 'skeeks\cms\console\controllers' ], 'ajaxfileupload' => [ 'controllerNamespace' => 'skeeks\yii2\ajaxfileupload\console\controllers', 'private_tmp_dir' => '@frontend/runtime/ajaxfileupload' ] ], 'components' => [ 'urlManager' => [ 'baseUrl' => '', //'hostInfo' => 'https://demo.ru' ] ], 'controllerMap' => [ 'migrate' => [ 'class' => 'yii\console\controllers\MigrateController', 'migrationPath' => [ '@app/migrations', '@skeeks/cms/migrations', ], ], ] ]; return $config;
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/config/_permissions.php
src/config/_permissions.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 20.03.2015 */ return [ 'rules' => [ [ 'class' => \skeeks\cms\rbac\AuthorRule::class, ], [ 'class' => \skeeks\cms\rbac\CmsLogRule::class, ], [ 'class' => \skeeks\cms\rbac\CmsUserRule::class, ], [ 'class' => \skeeks\cms\rbac\CmsTaskRule::class, ], [ 'class' => \skeeks\cms\rbac\CmsCompanyRule::class, ], ], 'roles' => [ [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_GUEST, 'description' => ['skeeks/cms', 'Unauthorized user'], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_USER, 'description' => ['skeeks/cms', 'Пользователь'], //Есть доступ к системе администрирования 'child' => [ 'permissions' => [ \skeeks\cms\components\Cms::UPA_PERMISSION, ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_WORKER, 'description' => ['skeeks/cms', 'Сотрудник'], 'child' => [ //Есть доступ к системе администрирования 'permissions' => [ \skeeks\cms\rbac\CmsManager::PERMISSION_ADMIN_ACCESS, 'cms/admin-storage-files', 'cms/admin-storage-files/index/own', "cms/admin-storage-files/delete-tmp-dir/own", "cms/admin-storage-files/download/own", "cms/admin-storage-files/delete/own", "cms/admin-storage-files/update/own", "cms/admin-cms-log/update-delete/own", "cms/admin-worker", "cms/admin-user", "cms/admin-user/manage/own", "cms/admin-task", "cms/admin-task/manage/own", ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_EDITOR, 'description' => ['skeeks/cms', 'Редактор контента'], 'child' => [ //Есть доступ к системе администрирования 'permissions' => [ \skeeks\cms\rbac\CmsManager::ROLE_WORKER, "cms/admin-element", "cms/admin-element/index", "cms/admin-element/create", "cms/admin-element/update/own", "cms/admin-element/delete/own", "cms/admin-tree", "cms/admin-tree/index", "cms/admin-tree/new-children", "cms/admin-tree/update/own", "cms/admin-tree/delete/own", "cms/admin-tree/move/own", "cms/admin-tree/resort/own", "cms/admin-storage-files", "cms/admin-storage-files/upload", "cms/admin-storage-files/index/own", "cms/admin-storage-files/delete-tmp-dir/own", "cms/admin-storage-files/download/own", "cms/admin-storage-files/delete/own", "cms/admin-storage-files/update/own", ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_MAIN_EDITOR, 'description' => ['skeeks/cms', 'Главный редактор контента'], 'child' => [ //Есть доступ к системе администрирования 'permissions' => [ \skeeks\cms\rbac\CmsManager::ROLE_WORKER, "cms/admin-element", "cms/admin-element/index", "cms/admin-element/create", "cms/admin-element/update", "cms/admin-element/delete/own", "cms/admin-tree", "cms/admin-tree/index", "cms/admin-tree/new-children", "cms/admin-tree/update", "cms/admin-tree/move", "cms/admin-tree/resort", "cms/admin-tree/delete/own", "cms/admin-storage-files", "cms/admin-storage-files/upload", "cms/admin-storage-files/index", "cms/admin-storage-files/update", "cms/admin-storage-files/download", "cms/admin-storage-files/delete/own", "cms/admin-storage-files/delete-tmp-dir", "cms/admin-cms-saved-filter", ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_MANGER, 'description' => ['skeeks/cms', 'Менеджер'], 'child' => [ //Есть доступ к системе администрирования 'permissions' => [ \skeeks\cms\rbac\CmsManager::ROLE_WORKER, "cms/admin-company", "cms/admin-company/manage/own", ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_MARKETER, 'description' => ['skeeks/cms', 'Маркетолог'], 'child' => [ //Есть доступ к системе администрирования 'permissions' => [ \skeeks\cms\rbac\CmsManager::ROLE_WORKER, "shop/admin-bonus-transaction", "shop/admin-discount", "shop/admin-discount-coupon", "shop/admin-shop-feedback", ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_ADMIN, 'description' => ['skeeks/cms', 'Admin'], 'child' => [ //Есть доступ к системе администрирования 'permissions' => [ \skeeks\cms\rbac\CmsManager::ROLE_WORKER, \skeeks\cms\rbac\CmsManager::PERMISSION_ROLE_ADMIN_ACCESS, "cms/admin-tree", "cms/admin-tree/index", "cms/admin-tree/new-children", "cms/admin-tree/update", "cms/admin-tree/delete", "cms/admin-tree/delete-multi", "cms/admin-tree/list", "cms/admin-tree/move", "cms/admin-tree/resort", "cms/admin-storage-files", "cms/admin-storage-files/upload", "cms/admin-storage-files/index", "cms/admin-storage-files/update", "cms/admin-storage-files/delete", "cms/admin-storage-files/delete-mult", "cms/admin-storage-files/download", "cms/admin-storage-files/delete-tmp-dir", "cms/admin-task", "cms/admin-user", "cms/admin-user/manage", "cms/admin-company", "cms/admin-company/manage", "cms/admin-cms-log/update-delete", ], ], ], [ 'name' => \skeeks\cms\rbac\CmsManager::ROLE_ROOT, 'description' => ['skeeks/cms', 'Superuser'], ], ], 'permissions' => [ [ 'name' => \skeeks\cms\rbac\CmsManager::PERMISSION_ROOT_ACCESS, 'description' => ['skeeks/cms', 'Возможности суперадминистратора'], ], [ 'name' => \skeeks\cms\rbac\CmsManager::PERMISSION_ROLE_ADMIN_ACCESS, 'description' => ['skeeks/cms', 'Возможности администратора'], ], [ 'name' => \skeeks\cms\components\Cms::UPA_PERMISSION, 'description' => ['skeeks/cms', 'Доступ к личному кабинету клиента'], ], [ 'name' => \skeeks\cms\rbac\CmsManager::PERMISSION_ADMIN_ACCESS, 'description' => ['skeeks/cms', 'Доступ к кабинету сотрудника'], ], [ 'name' => \skeeks\cms\rbac\CmsManager::PERMISSION_EDIT_VIEW_FILES, 'description' => ['skeeks/cms', 'Редактирование шаблонов'], ], [ 'name' => \skeeks\cms\rbac\CmsManager::PERMISSION_ADMIN_DASHBOARDS_EDIT, 'description' => ['skeeks/cms', 'Access to edit dashboards'], ], [ 'name' => 'cms/admin-storage-files/index', 'description' => ['skeeks/cms', 'Файловое хранилище | Прсмотр всех файлов'], ], [ 'name' => 'cms/admin-storage-files/index/own', 'description' => ['skeeks/cms', 'Файловое хранилище | Прсмотр только своих файлов'], ], [ 'name' => 'cms/admin-cms-saved-filter', 'description' => ['skeeks/cms', 'Сохраненные фильтры'], ], [ 'name' => 'cms/admin-company', 'description' => ['skeeks/cms', 'Компании'], ], [ 'name' => 'cms/admin-company/manage', 'description' => ['skeeks/cms', 'Управление компаниями'], ], [ 'name' => 'cms/admin-company/manage/own', 'description' => ['skeeks/cms', 'Управление компаниями (только доступные)'], 'child' => [ 'permissions' => [ 'cms/admin-company/manage', ], ], 'ruleName' => \skeeks\cms\rbac\CmsCompanyRule::NAME ], [ 'name' => 'cms/admin-tree', 'description' => ['skeeks/cms', 'Разделы сайта'], ], [ 'name' => 'cms/admin-task', 'description' => ['skeeks/cms', 'Задачи'], ], [ 'name' => 'cms/admin-task/manage', 'description' => ['skeeks/cms', 'Управление задачами'], ], [ 'name' => 'cms/admin-task/manage/own', 'description' => ['skeeks/cms', 'Управление задачами (только доступные)'], 'child' => [ 'permissions' => [ 'cms/admin-task/manage', ], ], 'ruleName' => \skeeks\cms\rbac\CmsTaskRule::NAME ], [ 'name' => 'cms/admin-user', 'description' => ['skeeks/cms', 'Клиенты'], ], [ 'name' => 'cms/admin-user/manage', 'description' => ['skeeks/cms', 'Управление клиентами'], ], [ 'name' => 'cms/admin-user/manage/own', 'description' => ['skeeks/cms', 'Управление клиентами (только доступные)'], 'child' => [ 'permissions' => [ 'cms/admin-user/manage', ], ], 'ruleName' => \skeeks\cms\rbac\CmsUserRule::NAME ], /** * Доступ к элементам */ [ 'name' => 'cms/admin-element', 'description' => ['skeeks/cms', 'Элементы'], ], [ 'name' => 'cms/admin-element/index', 'description' => ['skeeks/cms', 'Элементы | Список'], ], [ 'name' => 'cms/admin-element/create', 'description' => ['skeeks/cms', 'Элементы | Добавить'], ], [ 'name' => 'cms/admin-element/update', 'description' => ['skeeks/cms', 'Элементы | Редактировать'], ], [ 'name' => 'cms/admin-element/update/own', 'description' => ['skeeks/cms', 'Элементы | Редактировать (только свои)'], 'child' => [ 'permissions' => [ 'cms/admin-element/update', ], ], 'ruleName' => \skeeks\cms\rbac\AuthorRule::NAME ], [ 'name' => 'cms/admin-element/delete', 'description' => ['skeeks/cms', 'Элементы | Удалить'], ], [ 'name' => 'cms/admin-element/delete/own', 'description' => ['skeeks/cms', 'Элементы | Удалить (только свои)'], 'child' => [ 'permissions' => [ 'cms/admin-element/delete', ], ], 'ruleName' => \skeeks\cms\rbac\AuthorRule::NAME ], [ 'name' => 'cms/admin-worker', 'description' => ['skeeks/cms', 'Доступ к сотрудникам'], ], [ 'name' => 'cms/admin-cms-log/update-delete', 'description' => ['skeeks/cms', 'Обновление и удаление логов'], ], [ 'name' => 'cms/admin-cms-log/update-delete/own', 'description' => ['skeeks/cms', 'Обновление и удаление логов (только своих комментариев)'], 'child' => [ 'permissions' => [ 'cms/admin-cms-log/update-delete', ], ], 'ruleName' => \skeeks\cms\rbac\CmsLogRule::NAME ], ], ];
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/config/admin/menu.php
src/config/admin/menu.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 12.03.2015 */ /** * Меню контента * @return array */ function contentMenu() { $result = []; if ($contentTypes = \skeeks\cms\models\CmsContentType::find()->orderBy("priority ASC")->all()) { /** * @var $contentType \skeeks\cms\models\CmsContentType */ foreach ($contentTypes as $contentType) { $itemData = [ 'code' => "content-block-".$contentType->id, 'label' => $contentType->name, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.article.png'], ]; $contents = $contentType->getCmsContents()->andWhere(['is_visible' => 1])->all(); if ($contents) { foreach ($contents as $content) { $itemData['items'][] = [ 'label' => $content->name, 'url' => ["cms/admin-cms-content-element", "content_id" => $content->id], "activeCallback" => function ($adminMenuItem) use ($content) { return (bool)($content->id == \Yii::$app->request->get("content_id") && \Yii::$app->controller->uniqueId == 'cms/admin-cms-content-element'); }, "accessCallback" => function ($adminMenuItem) use ($content) { $permissionNames = "cms/admin-cms-content-element__".$content->id; foreach ([$permissionNames] as $permissionName) { if ($permission = \Yii::$app->authManager->getPermission($permissionName)) { if (!\Yii::$app->user->can($permission->name)) { return false; } } } return true; }, ]; } } if (isset($itemData['items'])) { $result[] = $itemData; } } } $contents = \skeeks\cms\models\CmsContent::find()->andWhere(['content_type' => null])->andWhere(['is_visible' => 1])->orderBy('priority')->all(); if ($contents) { foreach ($contents as $content) { $result[] = [ 'label' => $content->name, 'url' => ["cms/admin-cms-content-element", "content_id" => $content->id], "activeCallback" => function ($adminMenuItem) use ($content) { return (bool)($content->id == \Yii::$app->request->get("content_id") && \Yii::$app->controller->uniqueId == 'cms/admin-cms-content-element'); }, "accessCallback" => function ($adminMenuItem) use ($content) { $permissionNames = "cms/admin-cms-content-element__".$content->id; foreach ([$permissionNames] as $permissionName) { if ($permission = \Yii::$app->authManager->getPermission($permissionName)) { if (!\Yii::$app->user->can($permission->name)) { return false; } } } return true; }, ]; } } return $result; } ; /** * Меню контента * @return array */ function dashboardsMenu() { $result = []; $dashboards = \skeeks\cms\models\CmsDashboard::find()->orderBy("priority ASC")->all(); if (count($dashboards) > 1) { /** * @var $dashboard \skeeks\cms\models\CmsDashboard */ foreach ($dashboards as $dashboard) { $itemData = [ 'label' => $dashboard->name, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/dashboard.png'], 'url' => ["admin/admin-index/dashboard", "pk" => $dashboard->id], "activeCallback" => function ($adminMenuItem) { return (bool)(\Yii::$app->controller->action->uniqueId == 'admin/admin-index/dashboard' && \yii\helpers\ArrayHelper::getValue($adminMenuItem->urlData, 'pk') == \Yii::$app->request->get('pk')); }, ]; $result[] = $itemData; } return [ 'dashboard' => [ 'priority' => 90, 'label' => \Yii::t('skeeks/cms', 'Dashboards'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/dashboard.png'], 'items' => $result, ], ]; } elseif (count($dashboards) == 1) { $dashboard = $dashboards[0]; return [ 'dashboard' => [ 'priority' => 90, 'label' => $dashboard->name, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/dashboard.png'], 'url' => ["admin/admin-index/dashboard", "pk" => $dashboard->id], "activeCallback" => function ($adminMenuItem) { return (bool)(\Yii::$app->controller->action->uniqueId == 'admin/admin-index/dashboard' && \yii\helpers\ArrayHelper::getValue($adminMenuItem->urlData, 'pk') == \Yii::$app->request->get('pk')); }, ], ]; } else { $result[] = [ "label" => \Yii::t('skeeks/cms', "Рабочий стол 1"), "url" => ["admin/admin-index"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/dashboard.png'], ]; } return $result; } ; /** * Меню контента * @return array */ function contentEditMenu() { $result = []; if ($contentTypes = \skeeks\cms\models\CmsContentType::find()->orderBy("priority ASC")->all()) { /** * @var $contentType \skeeks\cms\models\CmsContentType */ foreach ($contentTypes as $contentType) { $itemData = [ 'code' => "content-block-edit-".$contentType->id, 'url' => ["/cms/admin-cms-content-type/update", "pk" => $contentType->id], 'label' => $contentType->name, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.article.png'], "activeCallback" => function ($adminMenuItem) { return (bool)(\Yii::$app->controller->action->uniqueId == 'cms/admin-cms-content-type/update' && \yii\helpers\ArrayHelper::getValue($adminMenuItem->urlData, 'pk') == \Yii::$app->request->get('pk')); }, ]; if ($contents = $contentType->cmsContents) { foreach ($contents as $content) { $itemData['items'][] = [ 'label' => $content->name, 'url' => ["cms/admin-cms-content/update", "pk" => $content->id], "activeCallback" => function ($adminMenuItem) { return (bool)(\Yii::$app->controller->action->uniqueId == 'cms/admin-cms-content/update' && \yii\helpers\ArrayHelper::getValue($adminMenuItem->urlData, 'pk') == \Yii::$app->request->get('pk')); }, ]; } } $result[] = $itemData; } } return $result; } ; function componentsMenu() { $result = []; if (\Yii::$app instanceof \yii\console\Application) { return $result; } foreach (\Yii::$app->getComponents(true) as $id => $data) { try { $loadedComponent = \Yii::$app->get($id); if ($loadedComponent instanceof \skeeks\cms\base\Component) { $result[] = [ 'label' => $loadedComponent->descriptor->name, 'url' => ["cms/admin-settings", "component" => $loadedComponent->className()], "activeCallback" => function ($adminMenuItem) { return (bool)(\Yii::$app->request->getUrl() == $adminMenuItem->getUrl()); }, ]; } } catch (\Exception $e) { } } return $result; } return array_merge(dashboardsMenu(), [ /*'dashboard' => [ 'priority' => 90, 'label' => \Yii::t('skeeks/cms', 'Dashboards'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/dashboard.png'], 'items' => dashboardsMenu(), ],*/ 'content' => [ 'priority' => 180, 'label' => \Yii::t('skeeks/cms', 'Сайт'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/sections.png'], "url" => ["cms/admin-tree"], 'items' => array_merge([ 'tree' => [ "label" => \Yii::t('skeeks/cms', "Разделы сайта"), "url" => ["cms/admin-tree"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/sections.png'], ], /*[ "label" => \Yii::t('skeeks/cms', "Sections"), "url" => ["cms/admin-tree"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/sections.png'], ],*/ /*[ "label" => \Yii::t('skeeks/cms', "File manager"), "url" => ["cms/admin-file-manager"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/folder.png'], ],*/ [ "label" => \Yii::t('skeeks/cms', "Сохраненные фильтры"), "url" => ["cms/admin-cms-saved-filter"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/storage_file.png'], ], [ "label" => \Yii::t('skeeks/cms', "Вопрос/Ответ"), "url" => ["cms/admin-cms-faq"], ], ], contentMenu()), ], 'file-storage' => [ 'priority' => 2000, "label" => \Yii::t('skeeks/cms', "Файловое хранилище"), "url" => ["cms/admin-storage-files"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/storage_file.png'], ], 'crm' => [ 'label' => \Yii::t('skeeks/cms', 'Клиенты и сделки'), 'priority' => 190, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/users_clients_group.png'], "url" => ["cms/admin-cms-company"], 'items' => [ [ 'label' => \Yii::t('skeeks/cms', 'Компании'), 'priority' => 190, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/users_clients_group.png'], "url" => ["cms/admin-cms-company"], ], [ 'label' => \Yii::t('skeeks/cms', 'Клиенты'), 'priority' => 200, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/users_clients_group.png'], "url" => ["cms/admin-user"], /*'items' => [ [ "label" => \Yii::t('skeeks/cms', "Users"), "url" => ["cms/admin-user"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/user.png'], 'priority' => 0, ], ],*/ ], [ 'label' => \Yii::t('skeeks/cms', 'Сделки'), 'priority' => 200, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icons-parnter.png'], "url" => ["cms/admin-cms-deal"], ], [ 'label' => \Yii::t('skeeks/cms', 'Счета'), 'priority' => 215, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.article.png'], "url" => ["cms/admin-cms-bill"], ], [ "label" => \Yii::t('skeeks/cms', 'Реквизиты'), 'priority' => 215, "url" => ["/cms/admin-cms-contractor"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/company.png'], ], ] ], 'task' => [ 'label' => \Yii::t('skeeks/cms', 'Задачи'), 'priority' => 190, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.article.png'], "url" => ["cms/admin-cms-task"], 'items' => [ [ 'label' => \Yii::t('skeeks/cms', 'Задачи'), 'priority' => 190, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.article.png'], "url" => ["cms/admin-cms-task"], ], [ 'label' => \Yii::t('skeeks/cms', 'Проекты'), 'priority' => 190, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.article.png'], "url" => ["cms/admin-cms-project"], ], ] ], 'settings' => [ 'priority' => 300, 'label' => \Yii::t('skeeks/cms', 'Settings'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/settings-big.png'], 'items' => [ 'siteinfo' => [ //'priority' => 290, 'label' => \Yii::t('skeeks/cms', 'Моя компания'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/information.png'], 'items' => [ [ 'label' => 'Общая', 'url' => ['cms/admin-cms-site-info'], ], [ 'label' => 'Телефоны', 'url' => ['cms/admin-cms-site-phone'], ], [ 'label' => 'Email-ы', 'url' => ['cms/admin-cms-site-email'], ], [ 'label' => 'Адреса', 'url' => ['cms/admin-cms-site-address'], ], [ 'label' => 'Социальные сети', 'url' => ['cms/admin-cms-site-social'], ], [ 'label' => 'Структура', /*"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/users_clients_group.png'],*/ 'url' => ['cms/admin-cms-department'], ], [ 'label' => 'Сотрудники', "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/users_clients_group.png'], 'url' => ['cms/admin-worker'], ], [ "label" => \Yii::t('skeeks/cms', 'Реквизиты'), "url" => ["/cms/admin-cms-contractor-our"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/company.png'], ], [ 'label' => 'Домены', 'url' => ['cms/admin-cms-site-domain'], ], ], ], 'list' => [ //'priority' => 290, 'label' => \Yii::t('skeeks/cms', 'Справочники'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/information.png'], 'items' => [ [ "name" => ['skeeks/measure', 'Страны'], "url" => ["cms/admin-cms-country"], "image" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/countries.png'], ], [ "label" => \Yii::t('skeeks/cms', "Languages"), "url" => ["cms/admin-cms-lang"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/ru.png'], ], [ "label" => \Yii::t('skeeks/cms', "Типы сделок"), "url" => ["cms/admin-cms-deal-type"], 'priority' => 900, /*"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/ru.png'],*/ ], [ "label" => \Yii::t('skeeks/cms', "Статусы компаний"), "url" => ["cms/admin-cms-company-status"], 'priority' => 900, /*"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/ru.png'],*/ ], [ "label" => \Yii::t('skeeks/cms', "Категории компаний"), "url" => ["cms/admin-cms-company-category"], 'priority' => 900, /*"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/ru.png'],*/ ], ], ], [ "label" => \Yii::t('skeeks/cms', 'Дизайн'), "url" => ["/cms/admin-cms-theme"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/themes.png'], ], [ "label" => \Yii::t('skeeks/cms', "Components"), "url" => ["cms/admin-settings"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/settings-big.png'], /*'items' => componentsMenu(),*/ ], [ "label" => \Yii::t('skeeks/cms', "Settings sections"), //"url" => ["cms/admin-cms-tree-type"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.tree.gif'], "items" => [ [ "label" => \Yii::t('skeeks/cms', "Properties"), "url" => ["cms/admin-cms-tree-type-property"], //"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.tree.gif'], ], [ "label" => \Yii::t('skeeks/cms', "Options"), "url" => ["cms/admin-cms-tree-type-property-enum"], //"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.tree.gif'], ], [ "label" => \Yii::t('skeeks/cms', "Types"), "url" => ["cms/admin-cms-tree-type"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.tree.gif'], ], ], ], [ "label" => \Yii::t('skeeks/cms', "Content settings"), //"url" => ["cms/admin-cms-content-type"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/content.png'], 'items' => [ [ 'url' => ["cms/admin-cms-content"], 'label' => \Yii::t('skeeks/cms', "Контент"), ], [ 'url' => ["cms/admin-cms-content-property"], 'label' => \Yii::t('skeeks/cms', "Properties"), ], [ 'url' => ["cms/admin-cms-content-property-enum"], 'label' => \Yii::t('skeeks/cms', "Options"), ], [ 'url' => ["cms/admin-cms-content-type"], 'label' => \Yii::t('skeeks/cms', "Группы контента"), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.tree.gif'], ], ], //contentEditMenu() ], [ "label" => \Yii::t('skeeks/cms', "SMS"), //"url" => ["cms/admin-cms-content-type"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/sms_icon-icons.com_67293.svg'], 'items' => [ [ 'url' => ["/cms/admin-cms-sms-provider"], 'label' => \Yii::t('skeeks/cms', "SMS провайдеры"), ], [ 'url' => ["/cms/admin-cms-sms-message"], 'label' => \Yii::t('skeeks/cms', "SMS сообщения"), ], ], //contentEditMenu() ], [ "label" => \Yii::t('skeeks/cms', "Авторизация по звонку"), //"url" => ["cms/admin-cms-content-type"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/telephone-call.png'], 'items' => [ [ 'url' => ["/cms/admin-cms-callcheck-provider"], 'label' => \Yii::t('skeeks/cms', "Провайдеры"), ], [ 'url' => ["/cms/admin-cms-callcheck-message"], 'label' => \Yii::t('skeeks/cms', "Дозвоны"), ], ], //contentEditMenu() ], [ "label" => \Yii::t('skeeks/cms', "User settings"), "url" => ["cms/admin-cms-user-universal-property"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/user.png'], "items" => [ [ "label" => \Yii::t('skeeks/rbac', 'Roles'), "url" => ["rbac/admin-role"], "img" => ['skeeks\cms\rbac\assets\RbacAsset', 'icons/users-role.png'], 'enabled' => true, 'priority' => 500, ], [ "label" => \Yii::t('skeeks/rbac', 'Privileges'), "url" => ["rbac/admin-permission"], "img" => ['skeeks\cms\rbac\assets\RbacAsset', 'icons/access.png'], 'enabled' => true, 'priority' => 500, ], [ "label" => \Yii::t('skeeks/cms', "User properties"), "url" => ["cms/admin-cms-user-universal-property"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/settings-big.png'], ], [ "label" => \Yii::t('skeeks/cms', "Options"), "url" => ["cms/admin-cms-user-universal-property-enum"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/settings-big.png'], ], ], ], 'clear' => [ "label" => \Yii::t('skeeks/cms', "Clearing temporary data"), "url" => ["cms/admin-clear"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/clear.png'], ], 'activity' => [ "label" => "Активность", "url" => ["cms/admin-cms-log/index"], "accessCallback" => function() { return \Yii::$app->user->can(\skeeks\cms\rbac\CmsManager::PERMISSION_ROLE_ADMIN_ACCESS); }, //"img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/clear.png'], ], ], ], /*'sites' => [ 'priority' => 310, 'label' => \Yii::t('skeeks/cms', 'Sites'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/www.png'], "url" => ["/cms/admin-cms-site"], ],*/ 'other' => [ 'priority' => 500, 'label' => \Yii::t('skeeks/cms', 'Additionally'), "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/other.png'], 'items' => [ /*'dev' => [ "label" => \Yii::t('skeeks/cms', "Для разработчика"), "url" => ["cms/admin-info"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.infoblock.png'], ],*/ /*[ 'label' => \Yii::t('skeeks/cms', 'Instruments'), 'priority' => 0, 'enabled' => true, "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/tools.png'], 'items' => [ [ "label" => \Yii::t('skeeks/cms', "Information"), "url" => ["cms/admin-info"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/icon.infoblock.png'], ], ], ],*/ /*'clear' => [ "label" => \Yii::t('skeeks/cms', "Clearing temporary data"), "url" => ["cms/admin-clear"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/clear.png'], ],*/ ], ], /*'sites' => [ 'priority' => 9000, "label" => \Yii::t('skeeks/cms', 'Sites'), "url" => ["/cms/admin-cms-site"], "img" => ['\skeeks\cms\assets\CmsAsset', 'images/icons/www.png'], ],*/ ]);
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/PropertyType.php
src/relatedProperties/PropertyType.php
<?php /** * Базовый тип свойства. * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 18.05.2015 */ namespace skeeks\cms\relatedProperties; use skeeks\cms\components\Cms; use skeeks\cms\IHasConfigForm; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\models\RelatedPropertyModel; use skeeks\cms\traits\TConfigForm; use yii\base\Model; use yii\helpers\ArrayHelper; use yii\helpers\Json; use yii\widgets\ActiveForm; /** * @property bool $isMultiple * @property mixed $defaultValue * * @property string $asText * @property string $asHtml * * Class PropertyType * @package skeeks\cms\relatedProperties */ abstract class PropertyType extends Model implements IHasConfigForm { use TConfigForm; /** * @var string */ public $id; /** * The name of the handler * @var string */ public $name; /** * Object properties is bound to the current handler * @var RelatedPropertyModel */ public $property; /** * Object form which will be completed item * @var ActiveForm */ public $activeForm; /** * The configuration form for the current state of the component settings * @param ActiveForm $form */ public function renderConfigForm(ActiveForm $form) { } /** * From the result of this function will depend on how the property values are stored in the database * @return bool */ public function getIsMultiple() { return false; } /** * Drawing form element * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = $this->activeForm->field($relatedPropertiesModel, $this->property->code); if (!$field) { return ''; } return $field; } /** * Adding validation rules to the object RelatedPropertiesModel * * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'safe'); if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required'); } return $this; } /** * The default value for this property * * @varsion > 3.0.2 * * @return null */ public function getDefaultValue(RelatedPropertiesModel $relatedPropertiesModel) { return null; } /** * @return string * @depricated */ public function getStringValue(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); /*print_r($this->property->relatedPropertiesModel->toArray());*/ /*echo "<br />_{$value}-{$this->property->relatedPropertiesModel->relatedElementModel->id}_<br />";*/ if (is_array($value)) { return Json::encode($value); } else { return (string)$value; } } /** * @see RelatedPropertyModel::getHandler() //удалить property * * @param array $fields * @param array $expand * @param $recursive * @return array */ public function toArray(array $fields = [], array $expand = [], $recursive = true) { $result = parent::toArray($fields, $expand, $recursive); ArrayHelper::remove($result, "property"); return $result; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { return $this->getStringValue($relatedPropertiesModel); } /** * @return string */ public function getAsHtml(RelatedPropertiesModel $relatedPropertiesModel) { return $this->getAsText($relatedPropertiesModel); } /** * Conversion property value received from the database * * @param mixed $valueFromDb * * @return mixed */ public function initValue($valueFromDb) { /* $valueFromDb = unserialize($valueFromDb); */ return $valueFromDb; } /** * Converting the property value before saving to database * * @param mixed $value * * @return mixed */ public function beforeSaveValue($value) { /* $value = serialize($value); */ return $value; } /** * Fires before the removal of the property value of the element base * * @return $this */ public function beforeDeleteValue() { /*$value = $this->property->relatedPropertiesModel->getAttribute($this->property->code); $valueToDb = serialize($value); $this->property->relatedPropertiesModel->setAttribute($this->property->code, $valueToDb);*/ return $this; } /** * TODO: It may be deprecated */ /** * TODO: It may be deprecated @version > 3.0.2 */ const CODE_STRING = 'S'; const CODE_NUMBER = 'N'; const CODE_FILE = 'F'; const CODE_STORAGE_FILE = 'A'; const CODE_LIST = 'L'; const CODE_TREE = 'T'; const CODE_ELEMENT = 'E'; const CODE_BOOL = 'B'; const CODE_RANGE = 'R'; /** * TODO: It may be deprecated @version > 3.0.2 * @var код типа свойства (логика приложения) */ public $code; /** * TODO: is deprecated @return string * @version > 3.0.2 */ public function getMultiple() { return $this->isMultiple ? Cms::BOOL_Y : Cms::BOOL_N; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/userPropertyTypes/UserPropertyTypeSelectFile.php
src/relatedProperties/userPropertyTypes/UserPropertyTypeSelectFile.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\userPropertyTypes; use skeeks\cms\backend\widgets\SelectModelDialogStorageFileSrcWidget; use skeeks\cms\components\Cms; use skeeks\cms\models\CmsContentElement; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; /** * Class UserPropertyTypeSelectFile * @package skeeks\cms\relatedProperties\userPropertyTypes */ class UserPropertyTypeSelectFile extends PropertyType { public $code = self::CODE_STRING; public $name = ""; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Standard file selection'); } } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'type' => \Yii::t('skeeks/cms', 'Type'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ]); } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $field->widget(SelectModelDialogStorageFileSrcWidget::class); return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'string'); return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/userPropertyTypes/UserPropertyTypeColor.php
src/relatedProperties/userPropertyTypes/UserPropertyTypeColor.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\userPropertyTypes; use skeeks\cms\components\Cms; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use skeeks\cms\widgets\ColorInput; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * Class UserPropertyTypeColor * @package skeeks\cms\relatedProperties\userPropertyTypes */ class UserPropertyTypeColor extends PropertyType { public $code = self::CODE_STRING; public $name = ""; public $showDefaultPalette = Cms::BOOL_Y; public $saveValueAs = Cms::BOOL_Y; public $useNative = Cms::BOOL_N; public $showAlpha = Cms::BOOL_Y; public $showInput = Cms::BOOL_Y; public $showPalette = Cms::BOOL_Y; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Choice of color'); } } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'showDefaultPalette' => \Yii::t('skeeks/cms', 'Show extended palette of colors'), 'saveValueAs' => \Yii::t('skeeks/cms', 'Format conservation values'), 'useNative' => \Yii::t('skeeks/cms', 'Use the native color selection'), 'showAlpha' => \Yii::t('skeeks/cms', 'Management transparency'), 'showInput' => \Yii::t('skeeks/cms', 'Show input field values'), 'showPalette' => \Yii::t('skeeks/cms', 'Generally show the palette'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['showDefaultPalette', 'string'], ['useNative', 'string'], ['showAlpha', 'string'], ['showInput', 'string'], ['showPalette', 'string'], [ ['showDefaultPalette', 'useNative', 'showAlpha', 'showInput', 'showPalette'], 'in', 'range' => array_keys(\Yii::$app->cms->booleanFormat()), ], ['saveValueAs', 'string'], ['saveValueAs', 'in', 'range' => array_keys(ColorInput::$possibleSaveAs)], ]); } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $pluginOptions = [ 'showAlpha' => (bool)($this->showAlpha === Cms::BOOL_Y), 'showInput' => (bool)($this->showInput === Cms::BOOL_Y), 'showPalette' => (bool)($this->showPalette === Cms::BOOL_Y), ]; $field->widget(ColorInput::className(), [ 'showDefaultPalette' => (bool)($this->showDefaultPalette === Cms::BOOL_Y), 'useNative' => (bool)($this->useNative === Cms::BOOL_Y), 'saveValueAs' => (string)$this->saveValueAs, 'pluginOptions' => $pluginOptions, ]); return $field; } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->field($this, 'showDefaultPalette')->checkbox([ 'uncheck' => \skeeks\cms\components\Cms::BOOL_N, 'value' => \skeeks\cms\components\Cms::BOOL_Y, ]); $result .= $activeForm->field($this, 'useNative')->checkbox([ 'uncheck' => \skeeks\cms\components\Cms::BOOL_N, 'value' => \skeeks\cms\components\Cms::BOOL_Y, ]); $result .= $activeForm->field($this, 'showInput')->hint(\Yii::t('skeeks/cms', 'This INPUT to opened the palette'))->checkbox([ 'uncheck' => \skeeks\cms\components\Cms::BOOL_N, 'value' => \skeeks\cms\components\Cms::BOOL_Y, ]); $result .= $activeForm->field($this, 'showAlpha')->checkbox([ 'uncheck' => \skeeks\cms\components\Cms::BOOL_N, 'value' => \skeeks\cms\components\Cms::BOOL_Y, ]); $result .= $activeForm->field($this, 'showPalette')->checkbox([ 'uncheck' => \skeeks\cms\components\Cms::BOOL_N, 'value' => \skeeks\cms\components\Cms::BOOL_Y, ]); $result .= $activeForm->field($this, 'saveValueAs')->radioList(\skeeks\cms\widgets\ColorInput::$possibleSaveAs); return $result; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'string'); return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/userPropertyTypes/UserPropertyTypeComboText.php
src/relatedProperties/userPropertyTypes/UserPropertyTypeComboText.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\userPropertyTypes; use skeeks\cms\components\Cms; use skeeks\cms\models\CmsContentElement; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; /** * Class UserPropertyTypeComboText * @package skeeks\cms\relatedProperties\userPropertyTypes */ class UserPropertyTypeComboText extends PropertyType { public $code = self::CODE_STRING; public $name = "Текст/CKEditor/HTML"; public function attributeLabels() { return array_merge(parent::attributeLabels(), [ //'type' => 'Тип', ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ //['type', 'string'], //['type', 'in', 'range' => array_keys(self::$types)], ]); } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $field->widget(\skeeks\cms\widgets\formInputs\comboText\ComboTextInputWidget::className(), [ 'ckeditorOptions' => [ 'relatedModel' => $relatedPropertiesModel->relatedElementModel ] ]); return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'string'); return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/userPropertyTypes/UserPropertyTypeDate.php
src/relatedProperties/userPropertyTypes/UserPropertyTypeDate.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\userPropertyTypes; use skeeks\cms\components\Cms; use skeeks\cms\models\CmsContentElement; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * Class UserPropertyTypeDate * @package skeeks\cms\relatedProperties\userPropertyTypes */ class UserPropertyTypeDate extends PropertyType { public $code = self::CODE_NUMBER; public $name = ""; /* static public $types = [ \kartik\datecontrol\DateControl::FORMAT_DATETIME => 'Дата и время', \kartik\datecontrol\DateControl::FORMAT_DATE => 'Только дата', //\kartik\datecontrol\DateControl::FORMAT_TIME => 'Только время', ];*/ public $type = \kartik\datecontrol\DateControl::FORMAT_DATETIME; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Datetime'); } } public static function types() { return [ \kartik\datecontrol\DateControl::FORMAT_DATETIME => \Yii::t('skeeks/cms', 'Datetime'), \kartik\datecontrol\DateControl::FORMAT_DATE => \Yii::t('skeeks/cms', 'Only date'), //\kartik\datecontrol\DateControl::FORMAT_TIME => 'Только время', ]; } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'type' => 'Тип', ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['type', 'string'], ['type', 'in', 'range' => array_keys(self::types())], ]); } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $field->widget(\kartik\datecontrol\DateControl::classname(), [ 'type' => $this->type, ]); return $field; } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { return $activeForm->field($this, 'type')->radioList(\skeeks\cms\relatedProperties\userPropertyTypes\UserPropertyTypeDate::types()); } /** * @return string * @depricated */ public function getStringValue(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); return \Yii::$app->formatter->asDatetime($value); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/models/RelatedElementPropertyModel.php
src/relatedProperties/models/RelatedElementPropertyModel.php
<?php /** * Модель связанного свойства. * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 18.05.2015 */ namespace skeeks\cms\relatedProperties\models; use skeeks\cms\components\Cms; use skeeks\cms\models\Core; use Yii; use yii\db\BaseActiveRecord; use yii\widgets\ActiveForm; /** * @property integer $id * @property integer $created_by * @property integer $updated_by * @property integer $created_at * @property integer $updated_at * @property integer $property_id * @property integer $element_id * @property string $value * @property integer $value_enum * @property string $value_num * @property string $value_element_id * @property string $value_enum_id * @property string $description * * @property RelatedPropertyModel $property * @property RelatedElementModel $element */ abstract class RelatedElementPropertyModel extends Core { /** * @inheritdoc */ public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'id' => Yii::t('skeeks/cms', 'ID'), 'created_by' => Yii::t('skeeks/cms', 'Created By'), 'updated_by' => Yii::t('skeeks/cms', 'Updated By'), 'created_at' => Yii::t('skeeks/cms', 'Created At'), 'updated_at' => Yii::t('skeeks/cms', 'Updated At'), 'property_id' => Yii::t('skeeks/cms', 'Property ID'), 'element_id' => Yii::t('skeeks/cms', 'Element ID'), 'value' => Yii::t('skeeks/cms', 'Value'), 'value_enum' => Yii::t('skeeks/cms', 'Value Enum'), 'value_num' => Yii::t('skeeks/cms', 'Value Num'), 'description' => Yii::t('skeeks/cms', 'Description'), ]); } /** * @inheritdoc */ public function rules() { return array_merge(parent::rules(), [ [['property_id', 'element_id'], 'integer'], [['description'], 'string', 'max' => 255], //[['value_string'], 'string', 'max' => 255], [['value', 'value_string'], 'string'], [ ['value_enum', 'value_int2'], 'filter', 'filter' => function($value) { $value = (int)$value; $filter_options = [ 'options' => [ 'default' => 0, 'min_range' => -2147483648, 'max_range' => 2147483647 ] ]; return filter_var($value, FILTER_VALIDATE_INT, $filter_options); } ], [['value_enum', 'value_int2'], 'integer'], [ ['value_num', 'value_num2'], 'filter', 'filter' => function($value) { $value = (float)$value; $min_range = -1.0E+14; $max_range = 1.0E+14; if ($value <= $min_range || $value >= $max_range) { return 0.0; } return $value; } ], [['value_num', 'value_num2'], 'number'], ['value_bool', 'boolean'], [ 'value_bool', 'filter', 'filter' => function($value) { $value = (bool)$value; return $value; } ], [['value_element_id', 'value_enum_id'], 'integer'], ]); } /** * @return \yii\db\ActiveQuery */ abstract public function getProperty(); /*{ return $this->hasOne(CmsContentProperty::className(), ['id' => 'property_id']); }*/ /** * @return \yii\db\ActiveQuery */ abstract public function getElement(); /*{ return $this->hasOne(CmsContentElement::className(), ['id' => 'element_id']); }*/ }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/models/RelatedPropertiesModel.php
src/relatedProperties/models/RelatedPropertiesModel.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 18.05.2015 */ namespace skeeks\cms\relatedProperties\models; use skeeks\cms\helpers\StringHelper; use skeeks\cms\models\behaviors\HasDescriptionsBehavior; use skeeks\cms\models\behaviors\HasStatus; use skeeks\cms\relatedProperties\PropertyType; use yii\base\DynamicModel; use yii\base\Exception; use yii\base\InvalidArgumentException; use yii\base\ModelEvent; use yii\caching\TagDependency; use yii\db\ActiveRecord; use yii\db\AfterSaveEvent; use yii\helpers\ArrayHelper; use yii\helpers\Json; /** * @property RelatedPropertyModel[] $properties * * Class RelatedPropertiesModel * @package skeeks\cms\relatedProperties\models */ class RelatedPropertiesModel extends DynamicModel { /** * @var string Ненужная вещь, нужна только для тестирования */ public $id = ''; /** * @var RelatedElementModel */ public $relatedElementModel = null; /** * @var RelatedPropertyModel[] */ private $_properties = []; /** * @var array */ private $_propertyValues = []; /** * @var array|null old attribute values indexed by attribute names. * This is `null` if the record [[isNewRecord|is new]]. */ private $_oldAttributes; protected $_attributeHints = []; protected $_attributeLabels = []; /** * Инициализация аттрибута * @param array $values * @param bool $safeOnly */ public function setAttributes($values, $safeOnly = true) { foreach ($values as $code => $value) { $this->hasAttribute($code); } parent::setAttributes($values, $safeOnly); } /** * @param $property * @return $this */ public function defineProperty($property) { $this->_defineByProperty($property); return $this; } protected function _defineByProperty($property) { //\Yii::info("_defineByProperty: {$this->relatedElementModel->id} {$this->id} {$property->code}", "dev"); /** * @var $property RelatedPropertyModel */ $this->defineAttribute($property->code, $property->handler->isMultiple ? [] : null); //$property->relatedPropertiesModel = $this; $property->addRules($this); $this->{$property->code} = $property->getDefaultValue($this); $this->_properties[$property->code] = $property; $this->_attributeLabels[$property->code] = $property->name; $this->_attributeHints[$property->code] = $property->hint; } /** * @param array $fields * @param array $expand * @param bool $recursive * @return array */ /*public function toArray(array $fields = [], array $expand = [], $recursive = true) { $this->initAllProperties(); $result = parent::toArray($fields, $expand, $recursive); /*if (!$result) { $this->initAllProperties(); return parent::toArray($fields, $expand, $recursive); } return $result; }*/ /** * @param RelatedPropertyModel $property * @param array $relatedElementProperties */ protected function _initPropertyValue($property, $relatedElementProperties = []) { $code = $property->code; if ($property->handler->isMultiple) { $values = []; $valuesModels = []; foreach ($relatedElementProperties as $propertyElementVal) { if ($propertyElementVal->property_id == $property->id) { $values[$propertyElementVal->id] = $propertyElementVal->value; $valuesModels[$propertyElementVal->id] = $propertyElementVal; } } $values = $property->handler->initValue($values); $this->setAttribute($code, $values); $this->_oldAttributes[$code] = $values; $this->_propertyValues[$code] = $valuesModels; } else { $value = null; $valueModel = null; foreach ($relatedElementProperties as $propertyElementVal) { if ($propertyElementVal->property_id == $property->id) { $value = $propertyElementVal->value; $valueModel = $propertyElementVal; break; } } $value = $property->handler->initValue($value); $this->setAttribute($code, $value); $this->_oldAttributes[$code] = $value; $this->_propertyValues[$code] = $valueModel; } } protected $_is_initAllProperties = false; /** * */ public function initAllProperties() { if ($this->_is_initAllProperties === true) { return true; } \Yii::beginProfile('init initAllProperties ' . $this->relatedElementModel->id); if ($this->relatedElementModel->relatedProperties) { foreach ($this->relatedElementModel->relatedProperties as $property) { $this->_defineByProperty($property); } } if ($relatedElementProperties = $this->relatedElementModel->relatedElementProperties) { foreach ($this->_properties as $code => $property) { $this->_initPropertyValue($property, $relatedElementProperties); } } $this->_is_initAllProperties = true; \Yii::endProfile('init initAllProperties ' . $this->relatedElementModel->id); } public function init() { // \Yii::beginProfile('init RP' . $this->relatedElementModel->id); parent::init(); $this->id = \Yii::$app->security->generateRandomString(5); $this->initAllProperties(); //\Yii::endProfile('init RP' . $this->relatedElementModel->id); } /** * Saves the current record. * * This method will call [[insert()]] when [[isNewRecord]] is true, or [[update()]] * when [[isNewRecord]] is false. * * For example, to save a customer record: * * ```php * $customer = new Customer; // or $customer = Customer::findOne($id); * $customer->name = $name; * $customer->email = $email; * $customer->save(); * ``` * * @param boolean $runValidation whether to perform validation (calling [[validate()]]) * before saving the record. Defaults to `true`. If the validation fails, the record * will not be saved to the database and this method will return `false`. * @param array $attributeNames list of attribute names that need to be saved. Defaults to null, * meaning all attributes that are loaded from DB will be saved. * @return boolean whether the saving succeeded (i.e. no validation errors occurred). */ public function save($runValidation = true, $attributeNames = null) { if ($runValidation && !$this->validate($attributeNames)) { \Yii::info('Model not updated due to validation error.', __METHOD__); return false; } if (!$this->beforeSave(false)) { return false; } $values = $this->getDirtyAttributes($attributeNames); if (empty($values)) { $this->afterSave(false, $values); return true; } $hasErrors = false; //TODO:Добавить транзакцию try { foreach ($this->_properties as $property) { $this->_saveRelatedPropertyValue($property); } } catch (\Exception $e) { $hasErrors = true; $this->addError($property->code, $e->getMessage()); } if ($hasErrors) { return false; } $changedAttributes = []; foreach ($values as $name => $value) { $changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null; $this->_oldAttributes[$name] = $value; } $this->afterSave(false, $changedAttributes); return true; } /** * @param $insert * @return bool */ public function beforeSave($insert) { $event = new ModelEvent(); $this->trigger($insert ? ActiveRecord::EVENT_BEFORE_INSERT : ActiveRecord::EVENT_BEFORE_UPDATE, $event); return $event->isValid; } /** * @param $insert * @param $changedAttributes */ public function afterSave($insert, $changedAttributes) { $this->trigger($insert ? ActiveRecord::EVENT_AFTER_INSERT : ActiveRecord::EVENT_AFTER_UPDATE, new AfterSaveEvent([ 'changedAttributes' => $changedAttributes, ])); } /** * @return RelatedPropertyModel[] */ public function getProperties() { return $this->_properties; } /** * @return bool */ public function delete() { $this->initAllProperties(); if (!$this->beforeDelete()) { return false; } try { foreach ($this->_properties as $property) { $this->_deleteRelatedPropertyValue($property); } } catch (\Exception $e) { return false; } $this->_oldAttributes = null; $this->afterDelete(); return true; } /** * @return bool */ public function beforeDelete() { $event = new ModelEvent(); $this->trigger(ActiveRecord::EVENT_BEFORE_DELETE, $event); return $event->isValid; } /** * */ public function afterDelete() { $this->trigger(ActiveRecord::EVENT_AFTER_DELETE); } /** * @param RelatedPropertyModel $property * @param $value * @return $this * @throws \Exception */ protected function _saveRelatedPropertyValue($property) { $value = $this->getAttribute($property->code); $element = $this->relatedElementModel; if ($element->isNewRecord) { throw new Exception("Additional property \"".$property->code."\" can not be saved until the stored parent model"); } if ($property->handler->isMultiple) { $propertyValues = $element->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); if ($propertyValues) { foreach ($propertyValues as $pv) { $pv->delete(); } } $values = (array)$this->getAttribute($property->code); $values = $property->handler->beforeSaveValue($values); if ($values) { foreach ($values as $key => $value) { if (empty($value)) { continue; } $className = $element->relatedElementPropertyClassName; /** * @var $productPropertyValue RelatedElementPropertyModel */ $productPropertyValue = new $className([ 'element_id' => $element->id, 'property_id' => $property->id, 'value' => (string)$value, 'value_enum' => $value, 'value_num' => $value, 'value_bool' => (bool)$value, 'value_num2' => $value, 'value_int2' => $value, 'value_string' => StringHelper::substr((string)$value, 0, 255) ]); if ($property->property_type == PropertyType::CODE_LIST) { $productPropertyValue->value_enum_id = (int)$value; } elseif ($property->property_type == PropertyType::CODE_ELEMENT) { $productPropertyValue->value_element_id = (int)$value; } else { $productPropertyValue->value_element_id = null; } if (!$productPropertyValue->save()) { throw new Exception("{$property->code} not save"); } } } } else { $value = $this->getAttribute($property->code); $value = $property->handler->beforeSaveValue($value); if ($productPropertyValue = $element->getRelatedElementProperties()->where(['property_id' => $property->id])->one()) { $productPropertyValue->value = (string)$value; $productPropertyValue->value_enum = $value; $productPropertyValue->value_num = $value; $productPropertyValue->value_bool = (bool)$value; $productPropertyValue->value_num2 = $value; $productPropertyValue->value_int2 = $value; $productPropertyValue->value_string = StringHelper::substr((string)$value, 0, 255); if ($property->property_type == PropertyType::CODE_LIST) { $productPropertyValue->value_enum_id = (int)$value; } elseif ($property->property_type == PropertyType::CODE_ELEMENT) { $productPropertyValue->value_element_id = (int)$value; } else { $productPropertyValue->value_element_id = null; } } else { $className = $element->relatedElementPropertyClassName; $productPropertyValue = new $className([ 'element_id' => $element->id, 'property_id' => $property->id, 'value' => (string)$value, 'value_enum' => $value, 'value_num' => $value, 'value_bool' => (bool)$value, 'value_num2' => $value, 'value_int2' => $value, 'value_string' => StringHelper::substr((string)$value, 0, 255), ]); if ($property->property_type == PropertyType::CODE_LIST) { $productPropertyValue->value_enum_id = (int) $value; } elseif($property->property_type == PropertyType::CODE_ELEMENT) { $productPropertyValue->value_element_id = (int) $value; } else { $productPropertyValue->value_element_id = null; } } if (empty($value)) { $productPropertyValue->delete(); } else { if (!$productPropertyValue->save()) { throw new Exception("{$property->code} not save. ".Json::encode($productPropertyValue->errors)); } } } return $this; } /** * @param RelatedPropertyModel $property * @param $value * @return $this * @throws \Exception */ protected function _deleteRelatedPropertyValue($property) { $element = $this->relatedElementModel; if ($element->isNewRecord) { throw new Exception("Additional property \"".$property->code."\" can not be saved until the stored parent model"); } if ($property->handler->isMultiple) { $property->handler->beforeDeleteValue(); $propertyValues = $element->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); if ($propertyValues) { foreach ($propertyValues as $pv) { $pv->delete(); } } } else { $property->handler->beforeDeleteValue(); $propertyValues = $element->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); if ($propertyValues) { foreach ($propertyValues as $pv) { $pv->delete(); } } } return $this; } /** * @inheritdoc */ public function attributeLabels() { return $this->_attributeLabels; } /** * @return array */ public function attributeHints() { return $this->_attributeHints; } /** * Loads default values from database table schema * * You may call this method to load default values after creating a new instance: * * ```php * // class Customer extends \yii\db\ActiveRecord * $customer = new Customer(); * $customer->loadDefaultValues(); * ``` * * @param boolean $skipIfSet whether existing value should be preserved. * This will only set defaults for attributes that are `null`. * @return $this the model instance itself. */ public function loadDefaultValues($skipIfSet = true) { foreach ($this->_properties as $property) { if ((!$skipIfSet || $this->{$property->code} === null)) { $this->{$property->code} = $property->getDefaultValue($this); } } return $this; /*foreach (static::getTableSchema()->columns as $column) { if ($column->defaultValue !== null && (!$skipIfSet || $this->{$column->name} === null)) { $this->{$column->name} = $column->defaultValue; } } return $this;*/ } /** * @param string $name * @return RelatedPropertyModel */ public function getRelatedProperty($name) { return ArrayHelper::getValue($this->_properties, $name); } /** * @param string $name * @return RelatedElementPropertyModel|RelatedElementPropertyModel[] */ public function getRelatedElementProperties($name) { return ArrayHelper::getValue($this->_propertyValues, $name); } /** * {@inheritdoc} */ /*public function __get($name) { $this->hasAttribute($name); return parent::__get($name); }*/ /** * {@inheritdoc} */ /*public function __set($name, $value) { $this->hasAttribute($name); return parent::__set($name, $value); }*/ /** * Returns a value indicating whether the model has an attribute with the specified name. * @param string $name the name of the attribute * @return boolean whether the model has an attribute with the specified name. */ public function hasAttribute($name) { //$this->initAllProperties(); return parent::hasAttribute($name); //\Yii::beginProfile('RP hasAttribute ' . $name); if (in_array($name, $this->attributes())) { //\Yii::endProfile('RP hasAttribute ' . $name); return true; } $profileKey = 'RP hasAttribute ' . $this->relatedElementModel->id . "_" . $name; \Yii::beginProfile($profileKey); $repClass = $this->relatedElementModel->relatedElementPropertyClassName; $rpClass = $this->relatedElementModel->relatedPropertyClassName; //TODO: Подумать, возможно getTableCacheTag нужно делать у какого то другого метода. Например у элементов контент это cmsContent как только изменились данные в таблице cmsContent тогда обновляется кэш. $tags = []; if (isset($this->relatedElementModel->tableCacheTag)) { $tags[] = $this->relatedElementModel->tableCacheTag; } $rp = new $rpClass(); $rep = new $repClass(); if (isset($rp->tableCacheTag)) { $tags[] = $rp->tableCacheTag; } if (isset($rep->tableCacheTag)) { $tags[] = $rep->tableCacheTag; } $dependency = new TagDependency([ 'tags' => $tags, ]); \Yii::endProfile($profileKey); $property = $this->relatedElementModel::getDb()->cache(function ($db) use ($name) { return $this->relatedElementModel->getRelatedProperties()->andWhere(['code' => $name])->one(); }, 3600 * 24, $dependency); if ($property) { /*$profileKey = 'RP _defineByProperty ' . $this->relatedElementModel->id . "_" . $name; \Yii::beginProfile($profileKey);*/ $this->_defineByProperty($property); /*\Yii::endProfile($profileKey);*/ $pv = $this->relatedElementModel::getDb()->cache(function ($db) use ($property) { return $this->relatedElementModel->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); }, 3600 * 24, $dependency); //$pv = $this->relatedElementModel->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); //$profileKey = 'RP _initPropertyValue ' . $this->relatedElementModel->id . "_" . $name; //\Yii::beginProfile($profileKey); $this->_initPropertyValue($property, (array)$pv); //\Yii::endProfile($profileKey); } if (in_array($name, $this->attributes())) { //\Yii::endProfile('RP hasAttribute ' . $name); return true; } //\Yii::endProfile('RP hasAttribute ' . $name); return false; } /** * Returns the named attribute value. * If this record is the result of a query and the attribute is not loaded, * null will be returned. * @param string $name the attribute name * @return mixed the attribute value. Null if the attribute is not set or does not exist. * @see hasAttribute() */ public function getAttribute($name) { //\Yii::beginProfile('RP getAttribute ' . $name); if ($this->hasAttribute($name)) { //\Yii::endProfile('RP getAttribute ' . $name); return $this->$name; } else { //\Yii::endProfile('RP getAttribute ' . $name); } return null; } /** * Sets the named attribute value. * @param string $name the attribute name * @param mixed $value the attribute value. * @throws InvalidArgumentException if the named attribute does not exist. * @see hasAttribute() */ public function setAttribute($name, $value) { if ($this->hasAttribute($name)) { $this->$name = $value; } else { throw new InvalidArgumentException(get_class($this).' '.\Yii::t('skeeks/cms', 'has no attribute named "{name}".', ['name' => $name])); } } /** * Returns the old attribute values. * @return array the old attribute values (name-value pairs) */ public function getOldAttributes() { return $this->_oldAttributes === null ? [] : $this->_oldAttributes; } /** * Sets the old attribute values. * All existing old attribute values will be discarded. * @param array|null $values old attribute values to be set. * If set to `null` this record is considered to be [[isNewRecord|new]]. */ public function setOldAttributes($values) { $this->_oldAttributes = $values; } /** * Returns the old value of the named attribute. * If this record is the result of a query and the attribute is not loaded, * `null` will be returned. * @param string $name the attribute name * @return mixed the old attribute value. `null` if the attribute is not loaded before * or does not exist. * @see hasAttribute() */ public function getOldAttribute($name) { return isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null; } /** * Sets the old value of the named attribute. * @param string $name the attribute name * @param mixed $value the old attribute value. * @throws InvalidArgumentException if the named attribute does not exist. * @see hasAttribute() */ public function setOldAttribute($name, $value) { if (isset($this->_oldAttributes[$name]) || $this->hasAttribute($name)) { $this->_oldAttributes[$name] = $value; } else { throw new InvalidArgumentException(get_class($this).' has no attribute named "'.$name.'".'); } } /** * Marks an attribute dirty. * This method may be called to force updating a record when calling [[update()]], * even if there is no change being made to the record. * @param string $name the attribute name */ public function markAttributeDirty($name) { unset($this->_oldAttributes[$name]); } /** * Returns a value indicating whether the named attribute has been changed. * @param string $name the name of the attribute. * @param bool $identical whether the comparison of new and old value is made for * identical values using `===`, defaults to `true`. Otherwise `==` is used for comparison. * This parameter is available since version 2.0.4. * @return bool whether the attribute has been changed */ public function isAttributeChanged($name, $identical = true) { if ($this->hasAttribute($name) && isset($this->_oldAttributes[$name])) { if ($identical) { return $this->getAttribute($name) !== $this->_oldAttributes[$name]; } return $this->getAttribute($name) != $this->_oldAttributes[$name]; } return $this->hasAttribute($name) || isset($this->_oldAttributes[$name]); } /** * Returns the attribute values that have been modified since they are loaded or saved most recently. * * The comparison of new and old values is made for identical values using `===`. * * @param string[]|null $names the names of the attributes whose values may be returned if they are * changed recently. If null, [[attributes()]] will be used. * @return array the changed attribute values (name-value pairs) */ public function getDirtyAttributes($names = null) { if ($names === null) { $names = $this->attributes(); } $names = array_flip($names); $attributes = []; if ($this->_oldAttributes === null) { foreach ($this->attributes as $name => $value) { if (isset($names[$name])) { $attributes[$name] = $value; } } } else { foreach ($this->attributes as $name => $value) { if (isset($names[$name]) && (!array_key_exists($name, $this->_oldAttributes) || $value !== $this->_oldAttributes[$name])) { $attributes[$name] = $value; } } } return $attributes; } /** * @param $name * @return string */ public function getAttributeAsText($name) { $property = $this->getRelatedProperty($name); /*print_r($property->toArray());*/ if (!$property) { return ''; } return $property->handler->getAsText($this); } /** * @param $name * @return string */ public function getAttributeAsHtml($name) { $property = $this->getRelatedProperty($name); if (!$property) { return ''; } return $property->handler->getAsHtml($this); } /** * @param $name * @return string * @deprecated */ public function getSmartAttribute($name) { $property = $this->getRelatedProperty($name); if (!$property) { return ''; } return $property->handler->getAsHtml($this); } /** * @param $name * * @return RelatedPropertyEnumModel|RelatedPropertyEnumModel[]|null */ public function getEnumByAttribute($name) { /** * @var $property RelatedPropertyModel */ $value = $this->getAttribute($name); $property = $this->getRelatedProperty($name); if ($property && $property->property_type == PropertyType::CODE_LIST) { if ($property->handler->isMultiple) { if ($property->enums) { $result = []; foreach ($property->enums as $enum) { if (in_array($enum->id, (array) $value)) { $result[$enum->code] = $enum; } } return $result; } } else { if ($property->enums) { $enums = (array)$property->enums; foreach ($enums as $enum) { if ($enum->id == $value) { return $enum; } } } return ""; } } return null; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/models/RelatedElementModel.php
src/relatedProperties/models/RelatedElementModel.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 18.05.2015 */ namespace skeeks\cms\relatedProperties\models; use skeeks\cms\models\behaviors\HasRelatedProperties; use skeeks\cms\models\behaviors\traits\HasRelatedPropertiesTrait; use skeeks\cms\models\Core; use Yii; use yii\web\ErrorHandler; /** * @property integer $id * @property integer $created_by * @property integer $updated_by * @property integer $created_at * @property integer $updated_at * @property integer $published_at * @property integer $published_to * @property integer $priority * @property string $active * @property string $name * @property string $code * @property string $description_short * @property string $description_full * @property string $files * @property integer $content_id * @property integer $tree_id * @property integer $show_counter * @property integer $show_counter_start */ abstract class RelatedElementModel extends \skeeks\cms\base\ActiveRecord { use HasRelatedPropertiesTrait; /** * @return array */ /*public function behaviors() { return array_merge(parent::behaviors(), [ //TODO: необходимо настроить поведение содержания связанных свойств. HasRelatedProperties::className() => [ 'class' => HasRelatedProperties::className(), 'valuesRelatedPropertiesClassName' => CmsContentElementProperty::className(), 'relatedPropertiesClassName' => CmsContentProperty::className(), ], ]); }*/ }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/models/RelatedPropertyModel.php
src/relatedProperties/models/RelatedPropertyModel.php
<?php /** * Модель связанного свойства. * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 18.05.2015 */ namespace skeeks\cms\relatedProperties\models; use skeeks\cms\base\ActiveRecord; use skeeks\cms\helpers\StringHelper; use skeeks\cms\measure\models\CmsMeasure; use skeeks\cms\models\behaviors\Serialize; use skeeks\cms\relatedProperties\PropertyType; use skeeks\cms\relatedProperties\propertyTypes\PropertyTypeText; use Yii; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * @property integer $id * @property integer $created_by * @property integer $updated_by * @property integer $created_at * @property integer $updated_at * @property string $name * @property string $code * @property integer $content_id * @property integer $priority * @property string $property_type * @property string $component * @property string $component_settings * @property string $hint * @property bool $is_required * @property bool $is_active * @property bool $is_multiple * @property null|string $cms_measure_code * * @property RelatedElementPropertyModel[] $elementProperties * @property RelatedPropertyEnumModel[] $enums * * @property PropertyType $handler * @property mixed $defaultValue * @property bool $isRequired * @property CmsMeasure $cmsMeasure */ abstract class RelatedPropertyModel extends ActiveRecord { const VALUE_TYPE_BOOL = 'bool'; const VALUE_TYPE_INT = 'int'; const VALUE_TYPE_NUM = 'num'; const VALUE_TYPE_INT_RANGE = 'int_range'; const VALUE_TYPE_NUM_RANGE = 'num_range'; //const VALUE_TYPE_JSON = 'json'; const VALUE_TYPE_STRING = 'string'; const VALUE_TYPE_TEXT = 'text'; const VALUE_TYPE_SOPTION = 'soption'; const VALUE_TYPE_ELEMENT = 'element'; const VALUE_TYPE_SECTION = 'section'; /** * @var RelatedPropertiesModel */ //public $relatedPropertiesModel = null; /** * @var null */ public $relatedPropertyEnumClassName = null; protected $_handler = null; public function behaviors() { return ArrayHelper::merge(parent::behaviors(), [ Serialize::className() => [ 'class' => Serialize::className(), 'fields' => ['component_settings'], ], ]); } public function init() { parent::init(); $this->on(self::EVENT_BEFORE_INSERT, [$this, "_processBeforeSave"]); $this->on(self::EVENT_BEFORE_UPDATE, [$this, "_processBeforeSave"]); $this->on(self::EVENT_BEFORE_DELETE, [$this, "_processBeforeDelete"]); } public function _processBeforeSave($e) { if ($handler = $this->handler) { $this->property_type = $handler->code; $this->is_multiple = $handler->isMultiple ? 1 : 0; } } public function _processBeforeDelete($e) { //TODO:: find all the elements associated with this feature and to remove them } /** * @inheritdoc */ public function attributeHints() { return array_merge(parent::attributeHints(), [ 'component' => Yii::t('skeeks/cms', 'От этого зависит как будет показываться свойство в форме редактирования.'), ]); } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'name' => Yii::t('skeeks/cms', 'Name'), 'code' => Yii::t('skeeks/cms', 'Code'), 'is_active' => Yii::t('skeeks/cms', 'Active'), 'priority' => Yii::t('skeeks/cms', 'Priority'), 'property_type' => Yii::t('skeeks/cms', 'Property Type'), 'is_multiple' => Yii::t('skeeks/cms', 'Multiple'), 'is_required' => Yii::t('skeeks/cms', 'Is Required'), 'component' => Yii::t('skeeks/cms', 'Элемент формы'), 'component_settings' => Yii::t('skeeks/cms', 'Component Settings'), 'hint' => Yii::t('skeeks/cms', 'Hint'), 'cms_measure_code' => Yii::t('skeeks/cms', 'Единица измерения'), ]); } /** * @inheritdoc */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['created_by', 'updated_by', 'created_at', 'updated_at', 'priority'], 'integer'], [['name', 'component'], 'required'], [['component_settings'], 'safe'], [['name', 'component', 'hint'], 'string', 'max' => 255], //[['code'], 'string', 'max' => 64], [ ['code'], function ($attribute) { if (!preg_match('/^[a-zA-Z]{1}[_a-zA-Z0-9]{1,255}$/', $this->$attribute)) { //if(!preg_match('/(^|.*\])([\w\.]+)(\[.*|$)/', $this->$attribute)) { $this->addError($attribute, \Yii::t('skeeks/cms', 'Use only letters of the alphabet in lower or upper case and numbers, the first character of the letter (Example {code})', ['code' => 'code1'])); } } }, ], [['property_type'], 'string', 'max' => 1], [ 'code', 'default', 'value' => function ($model, $attribute) { return "property".StringHelper::ucfirst(md5(\Yii::$app->security->generateRandomString(). time())); }, ], ['priority', 'default', 'value' => 500], [['is_required'], 'integer'], [['is_required'], 'default', 'value' => 0], [['is_multiple'], 'integer'], [['is_multiple'], 'default', 'value' => 0], [['is_active'], 'integer'], [['is_active'], 'default', 'value' => 1], [['cms_measure_code'], 'string'], [ ['cms_measure_code'], 'default', 'value' => null, ], [ ['cms_measure_code'], function ($model) { if (!$this->cmsMeasure) { $this->addError("cms_measure_code", "Указан код валюты которой нет в базе."); } }, ], ]); } /*{ return $this->hasMany(CmsContentElementProperty::className(), ['property_id' => 'id']); }*/ /** * @return \yii\db\ActiveQuery */ abstract public function getElementProperties(); /*{ return $this->hasMany(CmsContentPropertyEnum::className(), ['property_id' => 'id']); }*/ /** * @return \yii\db\ActiveQuery */ abstract public function getEnums(); /** * @return \yii\db\ActiveQuery */ public function getCmsMeasure() { return $this->hasOne(CmsMeasure::class, ['code' => 'cms_measure_code']); } /** * @param ActiveForm $activeForm * @param null $model * @return bool|\yii\widgets\ActiveField * @deprecated * */ public function renderActiveForm(ActiveForm $activeForm, $model = null) { $handler = $this->handler; if ($handler) { $handler->activeForm = $activeForm; } else { return false; } /*if ($model && !$this->relatedPropertiesModel) { $this->relatedPropertiesModel = $model->relatedPropertiesModel; }*/ return $handler->renderForActiveForm($model->relatedPropertiesModel); } /** * @return PropertyType * @throws \skeeks\cms\import\InvalidParamException */ public function getHandler() { if ($this->_handler !== null) { return $this->_handler; } if ($this->component) { try { /** * @var $component PropertyType */ $foundComponent = \Yii::$app->cms->getRelatedHandler($this->component); //TODO:: Подумать! Нужно чтобы создавался новый экземляр класса потому что в него передается property объект. В то же время хотелось бы чтобы объект handler собирался согласно настройкам конфига. $component = clone $foundComponent; //$component = \Yii::$app->cms->createRelatedHandler($this->component); //print_r($this->component_settings);die; $component->property = $this; $component->load($this->component_settings, ""); $this->_handler = $component; return $this->_handler; } catch (\Exception $e) { //\Yii::warning("Related property handler not found '{$this->component}' or load with errors: " . $e->getMessage(), self::className()); $component = new PropertyTypeText(); $component->property = $this; $this->_handler = $component; return $this->_handler; } } return null; } /** * @return bool */ public function getIsRequired() { return (bool)($this->is_required == 1); } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $elatedPropertiesModel) { $this->handler->addRules($elatedPropertiesModel); return $this; } /** * @return mixed */ public function getDefaultValue(RelatedPropertiesModel $relatedPropertiesModel) { return $this->handler->getDefaultValue($relatedPropertiesModel); } /** * @return string */ public function asText() { $result = parent::asText(); if ($this->cms_measure_code) { $result = $result." ({$this->cmsMeasure->asShortText})"; } return $result; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/models/RelatedPropertyEnumModel.php
src/relatedProperties/models/RelatedPropertyEnumModel.php
<?php /** * Модель значения связанного свойства. * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 18.05.2015 */ namespace skeeks\cms\relatedProperties\models; use skeeks\cms\models\Core; use Yii; /** * @property integer $id * @property integer $created_by * @property integer $updated_by * @property integer $created_at * @property integer $updated_at * @property integer $property_id * @property string $value * @property string $def * @property string $code * @property integer $priority * * @property RelatedPropertyModel $property */ abstract class RelatedPropertyEnumModel extends Core { /** * @inheritdoc */ public function attributeHints() { return array_merge(parent::attributeHints(), [ 'code' => "Не обязательно к заполнению. Это поле будет сгенерировано автоматически.", ]); } /** * @inheritdoc */ public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'id' => Yii::t('skeeks/cms', 'ID'), 'created_by' => Yii::t('skeeks/cms', 'Created By'), 'updated_by' => Yii::t('skeeks/cms', 'Updated By'), 'created_at' => Yii::t('skeeks/cms', 'Created At'), 'updated_at' => Yii::t('skeeks/cms', 'Updated At'), 'property_id' => Yii::t('skeeks/cms', 'Property'), 'value' => Yii::t('skeeks/cms', 'Value'), 'def' => Yii::t('skeeks/cms', 'Default'), 'code' => Yii::t('skeeks/cms', 'Code'), 'priority' => Yii::t('skeeks/cms', 'Priority'), ]); } /** * @inheritdoc */ public function rules() { return array_merge(parent::rules(), [ [['created_by', 'updated_by', 'created_at', 'updated_at', 'property_id', 'priority'], 'integer'], [['value', 'property_id'], 'required'], [['value'], 'string', 'max' => 255], [['def'], 'string', 'max' => 1], [['code'], 'string', 'max' => 32], [ 'code', 'default', 'value' => function($model, $attribute) { return md5(rand(1, 10) . time()); } ], [ 'priority', 'default', 'value' => function($model, $attribute) { return 500; } ], ]); } /** * @return \yii\db\ActiveQuery */ abstract public function getProperty(); /*{ return $this->hasOne(CmsContentProperty::className(), ['id' => 'property_id']); }*/ public function asText() { $text = parent::asText(); $text .= $this->value; return $text; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeNumber.php
src/relatedProperties/propertyTypes/PropertyTypeNumber.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\backend\widgets\forms\NumberInputWidget; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * Class PropertyTypeNumber * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeNumber extends PropertyType { public $code = self::CODE_NUMBER; public $name = ""; public $default_value = null; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Number'); } } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'default_value' => \Yii::t('skeeks/cms', 'Default Value'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['default_value', 'number'], ]); } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { return $activeForm->field($this, 'default_value'); } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $append = ''; if ($this->property->cms_measure_code) { $append = $this->property->cmsMeasure->asShortText; } //$field->textInput(); $field->widget(NumberInputWidget::class, [ 'options' => [ 'step' => '0.00000001' ], 'append' => $append ]); return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'number'); if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required'); } return $this; } /** * @varsion > 3.0.2 * * @return null */ public function getDefaultValue(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->default_value !== null) { return $this->default_value; } return; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeRange.php
src/relatedProperties/propertyTypes/PropertyTypeRange.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * * TODO: not ready * * Class PropertyTypeTextarea * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeRange extends PropertyType { public $code = self::CODE_RANGE; public $name = ""; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Range'); } } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ]); } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { return ''; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm() { $field = parent::renderForActiveForm(); if (in_array($this->fieldElement, array_keys(self::fieldElements()))) { $fieldElement = $this->fieldElement; if ($fieldElement == 'radioList' || $fieldElement == 'listbox') { $field->{$fieldElement}(\Yii::$app->formatter->booleanFormat); } else { $field->{$fieldElement}(); } } else { $field->textInput([]); } return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'boolean'); if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required'); } return $this; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); return (string)\Yii::$app->formatter->asBoolean($value); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeText.php
src/relatedProperties/propertyTypes/PropertyTypeText.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * Class PropertyTypeTextarea * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeText extends PropertyType { public $code = self::CODE_STRING; public $name = ""; public $default_value = null; /*static public $fieldElements = [ 'textarea' => 'Текстовое поле (textarea)', 'textInput' => 'Текстовая строка (input)', ];*/ public $fieldElement = 'textInput'; public $rows = 5; public static function fieldElements() { return [ 'textarea' => \Yii::t('skeeks/cms', 'Text field') . ' (textarea)', 'textInput' => \Yii::t('skeeks/cms', 'Text string') . ' (input)', 'hiddenInput' => \Yii::t('skeeks/cms', 'Скрытое поле') . ' (hiddenInput)', 'default_value' => \Yii::t('skeeks/cms', 'Default Value'), ]; } public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Text'); } } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'fieldElement' => \Yii::t('skeeks/cms', 'Element form'), 'rows' => \Yii::t('skeeks/cms', 'The number of lines of the text field'), 'default_value' => \Yii::t('skeeks/cms', 'Default Value'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['fieldElement', 'string'], ['rows', 'integer', 'min' => 1, 'max' => 50], ['default_value', 'string'], ]); } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->fieldSelect($this, 'fieldElement', \skeeks\cms\relatedProperties\propertyTypes\PropertyTypeText::fieldElements()); $result .= $activeForm->field($this, 'rows'); $result .= $activeForm->field($this, 'default_value'); return $result; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); if (in_array($this->fieldElement, array_keys(self::fieldElements()))) { $fieldElement = $this->fieldElement; if ($fieldElement == 'textarea') { $field->$fieldElement([ 'rows' => $this->rows ]); } if ($this->fieldElement == 'hiddenInput') { $field->label(false); } } else { $field->textInput([]); } return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { $relatedPropertiesModel->addRule($this->property->code, 'string'); if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required'); } return $this; } /** * @varsion > 3.0.2 * * @return null */ public function getDefaultValue(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->default_value !== null) { return $this->default_value; } return; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeFile.php
src/relatedProperties/propertyTypes/PropertyTypeFile.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\relatedProperties\PropertyType; /** * Class PropertyTypeFile * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeFile extends PropertyType { public $code = self::CODE_FILE; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'File'); } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeStorageFile.php
src/relatedProperties/propertyTypes/PropertyTypeStorageFile.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\models\behaviors\HasStorageFile; use skeeks\cms\models\behaviors\HasStorageFileMulti; use skeeks\cms\models\CmsStorageFile; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use skeeks\cms\widgets\AjaxFileUploadWidget; use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\widgets\ActiveForm; /** * Class PropertyTypeFile * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeStorageFile extends PropertyType { public $code = self::CODE_STORAGE_FILE; public $name = ""; public $is_multiple = false; public $accept = 'image/*'; public $allowExtensions = 'jpg,jpeg,gif,png'; public $minSize = 1024; public $maxSize = 10485760; public $maxFiles = 20; public function init() { parent::init(); if (!$this->name) { $this->name = "Файл"; } } /** * Файл с формой настроек, по умолчанию лежит в той же папке где и компонент. * * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->field($this, 'is_multiple')->checkbox(\Yii::$app->formatter->booleanFormat); $result .= $activeForm->field($this, 'accept'); $result .= $activeForm->field($this, 'allowExtensions'); $result .= $activeForm->field($this, 'minSize'); $result .= $activeForm->field($this, 'maxSize'); $result .= $activeForm->field($this, 'maxFiles'); return $result; } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'accept' => "Типы файлов разрешенные к загрузке", 'is_multiple' => \Yii::t('skeeks/cms', 'Multiple choice'), 'allowExtensions' => "Разрешенные расширения файлов к загрузке", 'minSize' => "Минимально допустимый размер файла", 'maxSize' => "Максимально допустимый размер файла", 'maxFiles' => "Максимальное количество файлов", ]); } public function attributeHints() { return array_merge(parent::attributeLabels(), [ 'accept' => "image/* - например", 'allowExtensions' => "Указать через запятую например: jpg,jpeg,gif,png", 'minSize' => "Значение указываетя в Kb", 'maxSize' => "Значение указываетя в Kb", 'maxFiles' => "Значение указывается если выбрана множественная загрузка", ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['is_multiple', 'boolean'], ['accept', 'string'], ['allowExtensions', 'string'], ['minSize', 'integer'], ['maxSize', 'integer'], ['maxFiles', 'integer'], ]); } /** * @return PropertyType */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->isMultiple) { $relatedPropertiesModel->attachBehavior(HasStorageFileMulti::class . $this->property->code, [ 'class' => HasStorageFileMulti::class, 'fields' => [$this->property->code] ]); $extensions = []; if ($this->allowExtensions) { $extensions = explode(",", $this->allowExtensions); } $relatedPropertiesModel->addRule($this->property->code, \skeeks\cms\validators\FileValidator::class, [ 'skipOnEmpty' => false, 'extensions' => $extensions, 'checkExtensionByMimeType' => false, 'maxFiles' => $this->maxFiles, 'maxSize' => $this->maxSize, 'minSize' => $this->minSize, ]); } else { $relatedPropertiesModel->attachBehavior(HasStorageFile::class . $this->property->code, [ 'class' => HasStorageFile::class, 'fields' => [$this->property->code] ]); $extensions = []; if ($this->allowExtensions) { $extensions = explode(",", $this->allowExtensions); } $relatedPropertiesModel->addRule($this->property->code, \skeeks\cms\validators\FileValidator::class, [ 'skipOnEmpty' => false, 'extensions' => $extensions, 'checkExtensionByMimeType' => false, 'maxFiles' => 1, 'maxSize' => $this->maxSize, 'minSize' => $this->minSize, ]); } return parent::addRules($relatedPropertiesModel); } /** * @return bool */ public function getIsMultiple() { return $this->is_multiple; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $field->widget( AjaxFileUploadWidget::class, [ 'accept' => $this->accept, 'multiple' => (bool) $this->isMultiple ] ); return $field; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); if ($this->isMultiple) { /** * @var CmsStorageFile $file */ $files = CmsStorageFile::find()->where(['id' => $value])->all(); if ($files) { return implode(", ", (array) ArrayHelper::map($files, "id", "original_name")); } } else { /** * @var CmsStorageFile $file */ $file = CmsStorageFile::findOne($value); if ($file) { return $file->original_name; } } return ""; } /** * @return string */ public function getAsHtml(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); if ($this->isMultiple) { /** * @var CmsStorageFile $file */ $files = CmsStorageFile::find()->where(['id' => $value])->all(); if ($files) { return implode(", ", (array) ArrayHelper::map($files, "id", function($file) { return Html::a($file->original_name, $file->absoluteSrc, [ 'data-pjax' => 0, 'target' => "_blank" ]); })); } } else { /** * @var CmsStorageFile $file */ $file = CmsStorageFile::findOne($value); if ($file) { return Html::a($file->original_name, $file->absoluteSrc, [ 'data-pjax' => 0, 'target' => "_blank" ]); } } return ""; } /** * @param mixed $value * @return mixed */ /*public function beforeSaveValue($value) { if (is_array($value)) { } else { if ($value && is_string($value) && ((string)(int)$value != (string)$value)) { try { $data = []; $file = \Yii::$app->storage->upload($value, $data); if ($file) { $value = $file->id; } else { $value = null; } } catch (\Exception $e) { \Yii::error($e->getMessage()); $value = null; } } } return $value; }*/ }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeElement.php
src/relatedProperties/propertyTypes/PropertyTypeElement.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\backend\widgets\SelectModelDialogContentElementWidget; use skeeks\cms\components\Cms; use skeeks\cms\models\CmsContentElement; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use skeeks\cms\widgets\AjaxSelect; use yii\helpers\ArrayHelper; use yii\helpers\Url; use yii\widgets\ActiveForm; /** * Class PropertyTypeElement * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeElement extends PropertyType { public $code = self::CODE_ELEMENT; public $dialogControllerUniqueId = ""; public $name = ""; const FIELD_ELEMENT_SELECT = "select"; const FIELD_ELEMENT_SELECT_MULTI = "selectMulti"; const FIELD_ELEMENT_RADIO_LIST = "radioList"; const FIELD_ELEMENT_CHECKBOX_LIST = "checkbox"; const FIELD_ELEMENT_SELECT_DIALOG = "selectDialog"; const FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE = "selectDialogMulti"; public $fieldElement = self::FIELD_ELEMENT_SELECT; public $content_id; public static function fieldElements() { return [ self::FIELD_ELEMENT_SELECT => \Yii::t('skeeks/cms', 'Выпадающий список'), self::FIELD_ELEMENT_SELECT_MULTI => \Yii::t('skeeks/cms', 'Выпадающий список (возможность выбора нескольких значений)'), //self::FIELD_ELEMENT_RADIO_LIST => \Yii::t('skeeks/cms', 'Radio Buttons (selecting one value)'), //self::FIELD_ELEMENT_CHECKBOX_LIST => \Yii::t('skeeks/cms', 'Checkbox List'), //self::FIELD_ELEMENT_LISTBOX => \Yii::t('skeeks/cms', 'ListBox'), //self::FIELD_ELEMENT_LISTBOX_MULTI => \Yii::t('skeeks/cms', 'ListBox Multi'), /*self::FIELD_ELEMENT_SELECT_DIALOG => \Yii::t('skeeks/cms', 'Selection widget in the dialog box'), self::FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE => \Yii::t('skeeks/cms', 'Selection widget in the dialog box (multiple choice)'),*/ ]; } public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Binding to an element'); } } /** * @return bool */ public function getIsMultiple() { if (in_array($this->fieldElement, [ self::FIELD_ELEMENT_SELECT_MULTI , self::FIELD_ELEMENT_CHECKBOX_LIST , self::FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE ])) { return true; } return false; } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'content_id' => \Yii::t('skeeks/cms', 'Content'), 'fieldElement' => \Yii::t('skeeks/cms', 'Form element type'), 'dialogControllerUniqueId' => \Yii::t('skeeks/cms', 'ID контроллера'), ]); } public function attributeHints() { return array_merge(parent::attributeHints(), [ 'fieldElement' => \Yii::t('skeeks/cms', 'Задайте то, как будет происходить выбор значений списка'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['content_id', 'integer'], ['fieldElement', 'in', 'range' => array_keys(static::fieldElements())], ['dialogControllerUniqueId', 'string'], ['fieldElement', 'string'], ]); } protected $_ajaxSelectUrl = null; public function setAjaxSelectUrl($url) { $this->_ajaxSelectUrl = $url; return $this; } public function getAjaxSelectUrl() { if ($this->_ajaxSelectUrl === null) { $r = new \ReflectionClass($this->property); $this->_ajaxSelectUrl = Url::to([ '/cms/ajax/autocomplete-eav-options', 'property_id' => $this->property->id, 'cms_site_id' => \Yii::$app->skeeks->site->id, 'property_class' => $r->getName(), ]); } return $this->_ajaxSelectUrl; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $find = CmsContentElement::find()->active(); if ($this->content_id) { $find->andWhere(['content_id' => $this->content_id]); } if (in_array($this->fieldElement, [ self::FIELD_ELEMENT_SELECT, self::FIELD_ELEMENT_RADIO_LIST, ])) { $config = []; if ($this->property->is_required) { $config['allowDeselect'] = false; } else { $config['allowDeselect'] = true; } //echo $this->property->relatedPropertiesModel->getAttribute($this->property->code); $field->widget( AjaxSelect::class, [ 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { return \yii\helpers\ArrayHelper::map(CmsContentElement::find()->where(['id' => $value])->all(), 'id', 'name'); }, ] ); } else { $field->widget( AjaxSelect::class, [ 'multiple' => true, 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { return \yii\helpers\ArrayHelper::map(CmsContentElement::find()->where(['id' => $value])->all(), 'id', 'name'); }, ] ); } if (!$field) { return ''; } return $field; } /** * @deprecated * @return \yii\widgets\ActiveField */ public function _renderForActiveFormOLD() { $field = parent::renderForActiveForm(); $find = CmsContentElement::find()->active(); if ($this->content_id) { $find->andWhere(['content_id' => $this->content_id]); } if ($this->fieldElement == self::FIELD_ELEMENT_SELECT) { $config = []; if ($this->property->is_required) { $config['allowDeselect'] = false; } else { $config['allowDeselect'] = true; } //echo $this->property->relatedPropertiesModel->getAttribute($this->property->code); $field->widget( AjaxSelect::class, [ 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { return \yii\helpers\ArrayHelper::map(CmsContentElement::find()->where(['id' => $value])->all(), 'id', 'name'); }, ] ); } elseif ($this->fieldElement == self::FIELD_ELEMENT_SELECT_MULTI) { $field->widget( AjaxSelect::class, [ 'multiple' => true, 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { return \yii\helpers\ArrayHelper::map(CmsContentElement::find()->where(['id' => $value])->all(), 'id', 'name'); }, ] ); } else { if ($this->fieldElement == self::FIELD_ELEMENT_SELECT_MULTI) { $field = $this->activeForm->fieldSelectMulti( $relatedPropertiesModel, $this->property->code, ArrayHelper::map($find->all(), 'id', 'name'), [] ); } else { if ($this->fieldElement == self::FIELD_ELEMENT_RADIO_LIST) { $field = parent::renderForActiveForm(); $field->radioList(ArrayHelper::map($find->all(), 'id', 'name')); } else { if ($this->fieldElement == self::FIELD_ELEMENT_CHECKBOX_LIST) { $field = parent::renderForActiveForm(); $field->checkboxList(ArrayHelper::map($find->all(), 'id', 'name')); } else { if ($this->fieldElement == self::FIELD_ELEMENT_SELECT_DIALOG) { $field = parent::renderForActiveForm(); $data = [ 'content_id' => $this->content_id ]; if ($this->dialogControllerUniqueId) { $data['dialogRoute'] = ["/" . $this->dialogControllerUniqueId]; } $field->widget( SelectModelDialogContentElementWidget::class, $data ); } else { if ($this->fieldElement == self::FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE) { $data = [ 'content_id' => $this->content_id, 'multiple' => true, ]; if ($this->dialogControllerUniqueId) { $data['dialogRoute'] = ["/" . $this->dialogControllerUniqueId]; } $field = parent::renderForActiveForm(); $field->widget( SelectModelDialogContentElementWidget::class, $data ); } } } } } } if (!$field) { return ''; } return $field; } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->fieldSelect($this, 'fieldElement', \skeeks\cms\relatedProperties\propertyTypes\PropertyTypeElement::fieldElements()); $result .= $activeForm->fieldSelect($this, 'content_id', \skeeks\cms\models\CmsContent::getDataForSelect()); $result .= $activeForm->field($this, 'dialogControllerUniqueId'); return $result; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->isMultiple) { $relatedPropertiesModel->addRule($this->property->code, 'safe'); } else { $relatedPropertiesModel->addRule($this->property->code, 'integer'); } if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required'); } return $this; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); if ($this->isMultiple) { $data = ArrayHelper::map(CmsContentElement::find()->where(['id' => $value])->all(), 'id', 'name'); return implode(', ', $data); } else { if ($element = CmsContentElement::find()->where(['id' => $value])->one()) { return $element->name; } return ""; } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeList.php
src/relatedProperties/propertyTypes/PropertyTypeList.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\models\CmsContentPropertyEnum; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use skeeks\cms\widgets\AjaxSelect; use skeeks\cms\widgets\Select; use yii\bootstrap\Alert; use yii\helpers\ArrayHelper; use yii\helpers\Url; use yii\widgets\ActiveForm; /** * Class PropertyTypeList * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeList extends PropertyType { public $enumRoute = 'cms/admin-cms-content-property-enum'; public $code = self::CODE_LIST; public $name = ""; const FIELD_ELEMENT_SELECT = "select"; const FIELD_ELEMENT_SELECT_MULTI = "selectMulti"; const FIELD_ELEMENT_LISTBOX = "listbox"; const FIELD_ELEMENT_LISTBOX_MULTI = "listboxmulti"; const FIELD_ELEMENT_RADIO_LIST = "radioList"; const FIELD_ELEMENT_CHECKBOX_LIST = "checkbox"; const FIELD_ELEMENT_SELECT_DIALOG = "selectDialog"; const FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE = "selectDialogMulti"; public static function fieldElements() { return [ self::FIELD_ELEMENT_SELECT => \Yii::t('skeeks/cms', 'Выпадающий список'), self::FIELD_ELEMENT_SELECT_MULTI => \Yii::t('skeeks/cms', 'Выпадающий список (возможность выбора нескольких значений)'), //self::FIELD_ELEMENT_RADIO_LIST => \Yii::t('skeeks/cms', 'Radio Buttons (selecting one value)'), //self::FIELD_ELEMENT_CHECKBOX_LIST => \Yii::t('skeeks/cms', 'Checkbox List'), //self::FIELD_ELEMENT_LISTBOX => \Yii::t('skeeks/cms', 'ListBox'), //self::FIELD_ELEMENT_LISTBOX_MULTI => \Yii::t('skeeks/cms', 'ListBox Multi'), /*self::FIELD_ELEMENT_SELECT_DIALOG => \Yii::t('skeeks/cms', 'Selection widget in the dialog box'), self::FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE => \Yii::t('skeeks/cms', 'Selection widget in the dialog box (multiple choice)'),*/ ]; } public $fieldElement = self::FIELD_ELEMENT_SELECT; public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'List'); } } /** * @return bool */ public function getIsMultiple() { if (in_array($this->fieldElement, [ self::FIELD_ELEMENT_SELECT_MULTI, self::FIELD_ELEMENT_CHECKBOX_LIST, self::FIELD_ELEMENT_LISTBOX_MULTI, self::FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE, ])) { return true; } return false; } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'fieldElement' => \Yii::t('skeeks/cms', 'Element form'), ]); } public function attributeHints() { return array_merge(parent::attributeHints(), [ 'fieldElement' => \Yii::t('skeeks/cms', 'Задайте то, как будет происходить выбор значений списка'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['fieldElement', 'required'], ['fieldElement', 'string'], ['fieldElement', 'in', 'range' => array_keys(static::fieldElements())], ]); } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->fieldSelect($this, 'fieldElement', \skeeks\cms\relatedProperties\propertyTypes\PropertyTypeList::fieldElements()); $controllers = \Yii::$app->createController($this->enumRoute); if ($controllers) { if ($controllerProperty = $controllers[0]) { /** * @var \skeeks\cms\backend\BackendAction $actionIndex * @var \skeeks\cms\backend\BackendAction $actionCreate */ $actionCreate = \yii\helpers\ArrayHelper::getValue($controllerProperty->actions, 'create'); $actionIndex = \yii\helpers\ArrayHelper::getValue($controllerProperty->actions, 'index'); if ($this->property->isNewRecord) { $result .= Alert::widget([ 'options' => [ 'class' => 'alert-info text-center', ], 'body' => \Yii::t('skeeks/cms', 'To start setting up options, save this property.'), ]); } else { $result .= Alert::widget([ 'options' => [ 'class' => 'alert-default text-center', ], 'body' => \Yii::t('skeeks/cms', 'Опции для этого списка задаются в отдельной вкладке, которая доступна после сохранения этого свойства.'), ]); } } } return $result; } protected $_ajaxSelectUrl = null; protected $_enumClass = null; public function setAjaxSelectUrl($url) { $this->_ajaxSelectUrl = $url; return $this; } public function getAjaxSelectUrl() { if ($this->_ajaxSelectUrl === null) { $r = new \ReflectionClass($this->property); $this->_ajaxSelectUrl = Url::to([ '/cms/ajax/autocomplete-eav-options', 'property_id' => $this->property->id, 'cms_site_id' => \Yii::$app->skeeks->site->id, 'property_class' => $r->getName(), 'property_enum_class' => $this->enumClass ]); } return $this->_ajaxSelectUrl; } public function setEnumClass($class) { $this->_enumClass = $class; return $this; } public function getEnumClass() { if ($this->_enumClass === null) { if ($enumClassName = $this->property->relatedPropertyEnumClassName) { $this->_enumClass = $enumClassName; } else { $r = new \ReflectionClass($this->property); $enumClassName = $r->getName() . "Enum"; $this->_enumClass = $enumClassName; } } return $this->_enumClass; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); $find = CmsContentPropertyEnum::find()->andWhere(['property_id' => $this->property->id]); if (in_array($this->fieldElement, [ self::FIELD_ELEMENT_SELECT, self::FIELD_ELEMENT_RADIO_LIST, ])) { $config = []; if ($this->property->is_required) { $config['allowDeselect'] = false; } else { $config['allowDeselect'] = true; } //echo $this->property->relatedPropertiesModel->getAttribute($this->property->code); $field->widget( AjaxSelect::class, [ 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { $class = $this->getEnumClass(); return \yii\helpers\ArrayHelper::map($class::find()->where(['id' => $value])->all(), 'id', 'value'); }, ] ); } else { $field->widget( AjaxSelect::class, [ 'multiple' => true, 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { $class = $this->getEnumClass(); return \yii\helpers\ArrayHelper::map($class::find()->where(['id' => $value])->all(), 'id', 'value'); }, ] ); } return $field; } /** * @deprecated * @return \yii\widgets\ActiveField */ public function _renderForActiveFormOld() { $field = parent::renderForActiveForm(); $find = CmsContentPropertyEnum::find()->andWhere(['property_id' => $this->property->id]); if ($this->fieldElement == self::FIELD_ELEMENT_SELECT) { $config = []; if ($this->property->is_required) { $config['allowDeselect'] = false; } else { $config['allowDeselect'] = true; } //echo $this->property->relatedPropertiesModel->getAttribute($this->property->code); $field->widget( AjaxSelect::class, [ 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { return \yii\helpers\ArrayHelper::map(CmsContentPropertyEnum::find()->where(['id' => $value])->all(), 'id', 'value'); }, ] ); } else { if ($this->fieldElement == self::FIELD_ELEMENT_SELECT_MULTI) { $field->widget( AjaxSelect::class, [ 'multiple' => true, 'ajaxUrl' => $this->getAjaxSelectUrl(), 'valueCallback' => function($value) { return \yii\helpers\ArrayHelper::map(CmsContentPropertyEnum::find()->where(['id' => $value])->all(), 'id', 'value'); }, ] ); } else { if ($this->fieldElement == self::FIELD_ELEMENT_RADIO_LIST) { $field = parent::renderForActiveForm(); $field->radioList(ArrayHelper::map($this->property->enums, 'id', 'value')); } else { if ($this->fieldElement == self::FIELD_ELEMENT_CHECKBOX_LIST) { $field = parent::renderForActiveForm(); $field->checkboxList(ArrayHelper::map($this->property->enums, 'id', 'value')); } else { if ($this->fieldElement == self::FIELD_ELEMENT_LISTBOX_MULTI) { $field = parent::renderForActiveForm(); $field->listBox(ArrayHelper::map($this->property->enums, 'id', 'value'), [ 'size' => 5, 'multiple' => 'multiple', ]); } else { if ($this->fieldElement == self::FIELD_ELEMENT_LISTBOX) { $field = parent::renderForActiveForm(); $field->listBox(ArrayHelper::map($this->property->enums, 'id', 'value'), [ 'size' => 1, ]); } else { if ($this->fieldElement == self::FIELD_ELEMENT_SELECT_DIALOG) { $field = parent::renderForActiveForm(); $field->widget( \skeeks\cms\backend\widgets\SelectModelDialogWidget::class, [ 'modelClassName' => \skeeks\cms\models\CmsContentPropertyEnum::class, 'dialogRoute' => [ '/cms/admin-cms-content-property-enum', 'CmsContentPropertyEnum' => [ 'property_id' => $this->property->id, ], ], ] ); } else { if ($this->fieldElement == self::FIELD_ELEMENT_SELECT_DIALOG_MULTIPLE) { $field = parent::renderForActiveForm(); $field->widget( \skeeks\cms\backend\widgets\SelectModelDialogWidget::class, [ 'modelClassName' => \skeeks\cms\models\CmsContentPropertyEnum::class, 'dialogRoute' => [ '/cms/admin-cms-content-property-enum', 'CmsContentPropertyEnum' => [ 'property_id' => $this->property->id, ], ], 'multiple' => true, ] ); } else { $field = $this->activeForm->fieldSelect( $this->property->relatedPropertiesModel, $this->property->code, ArrayHelper::map($this->property->enums, 'id', 'value'), [] ); } } } } } } } } return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->isMultiple) { $relatedPropertiesModel->addRule($this->property->code, 'safe'); } else { $relatedPropertiesModel->addRule($this->property->code, 'integer'); } if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required'); } return $this; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); if ($this->isMultiple) { $result = []; $data = $this->property->getEnums()->andWhere(['id' => $value])->select(['code', 'value'])->limit(10)->asArray()->all(); if ($data) { $result = ArrayHelper::map($data, 'code', 'value'); } return implode(", ", $result); } else { if (isset(self::$propertyEnumValues[$this->property->id][$value])) { return self::$propertyEnumValues[$this->property->id][$value]; } else { if ($enum = $this->property->getEnums()->andWhere(['id' => $value])->one()) { if ($enum) { self::$propertyEnumValues[$this->property->id][$value] = $enum->value; return self::$propertyEnumValues[$this->property->id][$value]; } } self::$propertyEnumValues[$this->property->id][$value] = ""; return ""; } /*if ($this->property->enums) { $enums = (array)$this->property->enums; foreach ($enums as $enum) { if ($enum->id == $value) { return $enum->value; } } }*/ //return ""; } } static public $propertyEnumValues = []; }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeBool.php
src/relatedProperties/propertyTypes/PropertyTypeBool.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * Class PropertyTypeTextarea * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeBool extends PropertyType { public $code = self::CODE_BOOL; public $name = ""; public $default_value = null; public $fieldElement = 'radioInput'; public $rows = 5; public static function fieldElements() { return [ 'radioList' => \Yii::t('skeeks/cms', 'Radio'), 'checkbox' => \Yii::t('skeeks/cms', 'Checkbox'), 'listBox' => \Yii::t('skeeks/cms', 'listBox'), ]; } public function init() { parent::init(); if (!$this->name) { $this->name = \Yii::t('skeeks/cms', 'Yes/No'); } } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'fieldElement' => \Yii::t('skeeks/cms', 'Element form'), 'default_value' => \Yii::t('skeeks/cms', 'Default Value'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['fieldElement', 'string'], ['default_value', 'boolean'], ]); } /** * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->fieldSelect($this, 'fieldElement', self::fieldElements()); $result .= $activeForm->field($this, 'default_value')->radioList(\Yii::$app->formatter->booleanFormat); return $result; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); if (in_array($this->fieldElement, array_keys(self::fieldElements()))) { $fieldElement = $this->fieldElement; if ($relatedPropertiesModel->relatedElementModel->isNewRecord && $this->getDefaultValue($relatedPropertiesModel)) { $relatedPropertiesModel->setAttribute($this->property->code, $this->getDefaultValue($relatedPropertiesModel)); } if ($fieldElement == 'radioList' || $fieldElement == 'listBox') { $field->{$fieldElement}(\Yii::$app->formatter->booleanFormat); } else { $field->{$fieldElement}(); } } else { $field->textInput([]); } return $field; } /** * @varsion > 3.0.2 * * @return $this */ public function addRules(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->property->isRequired) { $relatedPropertiesModel->addRule($this->property->code, 'required', [ 'requiredValue' => '1', 'message' => \Yii::t('yii', '{attribute} cannot be blank.'), ]); } else { $relatedPropertiesModel->addRule($this->property->code, 'boolean', [ 'trueValue' => '1', 'falseValue' => '0' ]); } return $this; } /** * @varsion > 3.0.2 * * @return null */ public function getDefaultValue(RelatedPropertiesModel $relatedPropertiesModel) { if ($this->default_value !== null) { return $this->default_value; } return; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); return (string)\Yii::$app->formatter->asBoolean($value); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/relatedProperties/propertyTypes/PropertyTypeTree.php
src/relatedProperties/propertyTypes/PropertyTypeTree.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 30.04.2015 */ namespace skeeks\cms\relatedProperties\propertyTypes; use skeeks\cms\backend\widgets\SelectModelDialogTreeWidget; use skeeks\cms\models\CmsTree; use skeeks\cms\relatedProperties\models\RelatedPropertiesModel; use skeeks\cms\relatedProperties\PropertyType; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; /** * Class PropertyTypeTree * @package skeeks\cms\relatedProperties\propertyTypes */ class PropertyTypeTree extends PropertyType { public $code = self::CODE_TREE; public $name = "Привязка к разделу"; public $is_multiple = false; public $root_tree_id = null; const FIELD_ELEMENT_DEFAULT = "selectDefault"; const FIELD_ELEMENT_SELECT_DIALOG = "selectDialog"; public $fieldElement = self::FIELD_ELEMENT_DEFAULT; public static function fieldElements() { return [ self::FIELD_ELEMENT_DEFAULT => \Yii::t('skeeks/cms', 'Standard selection element'), self::FIELD_ELEMENT_SELECT_DIALOG => \Yii::t('skeeks/cms', 'Selection in the dialog box'), ]; } /** * Файл с формой настроек, по умолчанию лежит в той же папке где и компонент. * * @return string */ public function renderConfigFormFields(ActiveForm $activeForm) { $result = $activeForm->field($this, 'is_multiple')->checkbox(\Yii::$app->formatter->booleanFormat); $result .= $activeForm->fieldSelect($this, 'fieldElement', static::fieldElements()); $result .= $activeForm->field($this, 'root_tree_id')->widget( ///\skeeks\cms\widgets\formInputs\selectTree\SelectTreeInputWidget::class SelectModelDialogTreeWidget::class ); return $result; } public function attributeLabels() { return array_merge(parent::attributeLabels(), [ 'is_multiple' => \Yii::t('skeeks/cms', 'Multiple choice'), 'fieldElement' => \Yii::t('skeeks/cms', 'Form element type'), 'root_tree_id' => \Yii::t('skeeks/cms', 'Root partition'), ]); } public function rules() { return ArrayHelper::merge(parent::rules(), [ ['is_multiple', 'boolean'], ['fieldElement', 'in', 'range' => array_keys(static::fieldElements())], ['fieldElement', 'string'], ['root_tree_id', 'integer'], ]); } /** * @return bool */ public function getIsMultiple() { return $this->is_multiple; } /** * @return \yii\widgets\ActiveField */ public function renderForActiveForm(RelatedPropertiesModel $relatedPropertiesModel) { $field = parent::renderForActiveForm($relatedPropertiesModel); if ($this->fieldElement == static::FIELD_ELEMENT_SELECT_DIALOG) { $options = [ "multiple" => $this->isMultiple ? true : false, ]; if ($this->root_tree_id) { $options['dialogRoute'] = ['/cms/admin-tree', 'root_id' => $this->root_tree_id]; } $field->widget( SelectModelDialogTreeWidget::className(), $options ); } else { $rootTreeModels = []; if ($this->root_tree_id) { $rootTreeModels = CmsTree::findAll($this->root_tree_id); } $field->widget( \skeeks\cms\widgets\formInputs\selectTree\SelectTreeInputWidget::className(), [ "multiple" => $this->isMultiple ? true : false, 'treeWidgetOptions' => [ 'models' => $rootTreeModels, ], ] ); } return $field; } /** * @return string */ public function getAsText(RelatedPropertiesModel $relatedPropertiesModel) { $value = $relatedPropertiesModel->getAttribute($this->property->code); if ($this->isMultiple) { $data = ArrayHelper::map(CmsTree::find()->where(['id' => $value])->all(), 'id', 'name'); return implode(', ', $data); } else { if ($element = CmsTree::find()->where(['id' => $value])->one()) { return $element->name; } return ""; } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/LongTextColumnData.php
src/grid/LongTextColumnData.php
<?php /** * LongTextColumnData * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 30.10.2014 * @since 1.0.0 */ namespace skeeks\cms\grid; use skeeks\cms\helpers\StringHelper; use yii\grid\DataColumn; /** * Class LongTextColumnData * @package skeeks\cms\grid */ class LongTextColumnData extends DataColumn { public $maxLength = 200; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $text = $model->{$this->attribute}; return "<small>" . StringHelper::substr($text, 0, $this->maxLength) . ((StringHelper::strlen($text) > $this->maxLength) ? " ..." : "") . "</small>"; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/SiteColumn.php
src/grid/SiteColumn.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (�����) * @date 01.09.2015 */ namespace skeeks\cms\grid; use skeeks\cms\models\CmsSite; use yii\grid\DataColumn; /** * Class SiteColumn * @package skeeks\cms\grid */ class SiteColumn extends DataColumn { public $attribute = 'cms_site_id'; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($model->site && $model->site instanceof CmsSite) { $site = $model->site; } else { } if ($site) { return $site->name; } return null; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/DateColumn.php
src/grid/DateColumn.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\grid; use yii\grid\DataColumn; /** * @author Semenov Alexander <semenov@skeeks.com> */ class DateColumn extends DataColumn { public $filter = false; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $timestamp = $model->{$this->attribute}; return \Yii::$app->formatter->asDate($timestamp); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/BooleanColumn.php
src/grid/BooleanColumn.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 26.03.2015 */ namespace skeeks\cms\grid; use skeeks\cms\components\Cms; use yii\grid\DataColumn; /** * Class CreatedAtColumn * @package skeeks\cms\grid */ class BooleanColumn extends DataColumn { /** * @var string the horizontal alignment of each column. Should be one of * 'left', 'right', or 'center'. Defaults to `center`. */ public $hAlign = 'center'; /** * @var string the width of each column (matches the CSS width property). * Defaults to `90px`. * @see http://www.w3schools.com/cssref/pr_dim_width.asp */ public $width = '90px'; /** * @var string|array in which format should the value of each data model be displayed * Defaults to `raw`. * [[\yii\base\Formatter::format()]] or [[\yii\i18n\Formatter::format()]] is used. */ public $format = 'raw'; /** * @var boolean|string|Closure the page summary that is displayed above the footer. * Defaults to false. */ public $pageSummary = false; /** * @var string label for the true value. Defaults to `Active`. */ public $trueLabel; /** * @var string label for the false value. Defaults to `Inactive`. */ public $falseLabel; /** * @var null */ public $falseValue = Cms::BOOL_N; public $trueValue = Cms::BOOL_Y; /** * @var string icon/indicator for the true value. If this is not set, it will use the value from `trueLabel`. * If GridView `bootstrap` property is set to true - it will default to [[GridView::ICON_ACTIVE]] * `<span class="glyphicon glyphicon-ok text-success"></span>` */ public $trueIcon = false; /** * @var string icon/indicator for the false value. If this is null, it will use the value from `falseLabel`. * If GridView `bootstrap` property is set to true - it will default to [[GridView::ICON_INACTIVE]] * `<span class="fa fa-times text-danger"></span>` */ public $falseIcon = false; /** * @var bool whether to show null value as a false icon. */ public $showNullAsFalse = false; public $contentOptions = [ 'style' => 'width: 70px;' ]; public $headerOptions = [ 'style' => 'width: 70px;' ]; /** * @inheritdoc */ public function init() { if (empty($this->trueLabel)) { $this->trueLabel = \Yii::t('yii', 'Yes'); } if (empty($this->falseLabel)) { $this->falseLabel = \Yii::t('yii', 'No'); } if (!$this->filter) { $this->filter = [$this->trueValue => $this->trueLabel, $this->falseValue => $this->falseLabel]; } if ($this->trueIcon === false) { $this->trueIcon = '<span class="text-success" title="' . $this->trueLabel . '">✓</span>'; } if ($this->falseIcon === false) { $this->falseIcon = '<span class="text-danger" title="' . $this->falseLabel . '">x</span>'; } parent::init(); } /** * @inheritdoc */ public function getDataCellValue($model, $key, $index) { /*if (!isset($model->{$key})) { return ''; }*/ $value = parent::getDataCellValue($model, $key, $index); if (is_integer($value)) { if ($value == 0) { return $this->falseIcon; } else { return $this->trueIcon; } } if (is_string($value)) { if ($value == "N") { return $this->falseIcon; } else { return $this->trueIcon; } } if ($this->trueValue !== true) { if ($value == $this->falseValue) { return $this->falseIcon; } else { return $this->trueIcon; } } else { if ($value !== null) { return $value ? $this->trueIcon : $this->falseIcon; } return $value . ($this->showNullAsFalse ? $this->falseIcon : $value); } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/UpdatedByColumn.php
src/grid/UpdatedByColumn.php
<?php /** * UpdatedByColumn * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 30.10.2014 * @since 1.0.0 */ namespace skeeks\cms\grid; /** * Class CreatedByColumn * @package skeeks\cms\grid */ class UpdatedByColumn extends UserColumnData { public $attribute = "updated_by"; }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/ComponentSettingsColumn.php
src/grid/ComponentSettingsColumn.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 29.05.2015 */ namespace skeeks\cms\grid; use skeeks\cms\base\Component; use skeeks\cms\components\Cms; use skeeks\cms\models\CmsSite; use skeeks\cms\models\User; /** * Class LongTextColumnData * @package skeeks\cms\grid */ class ComponentSettingsColumn extends BooleanColumn { /** * @var Component */ public $component = null; public $label = 'Наличие настроек'; /** * @inheritdoc */ public function getDataCellValue($model, $key, $index) { $settings = null; if ($this->component === null) { return $this->_result(Cms::BOOL_N); } if ($model instanceof CmsSite) { $settings = \skeeks\cms\models\CmsComponentSettings::findByComponentSite($this->component, $model)->one(); } if ($model instanceof User) { $settings = \skeeks\cms\models\CmsComponentSettings::findByComponentUser($this->component, $model)->one(); } if ($settings) { return $this->_result(Cms::BOOL_Y); } return $this->_result(Cms::BOOL_N); } /** * @inheritdoc */ protected function _result($value) { if ($this->trueValue !== true) { if ($value == $this->falseValue) { return $this->falseIcon; } else { return $this->trueIcon; } } else { if ($value !== null) { return $value ? $this->trueIcon : $this->falseIcon; } return $this->showNullAsFalse ? $this->falseIcon : $value; } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/DateTimeColumnData.php
src/grid/DateTimeColumnData.php
<?php /** * DateTimeColumnData * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 30.10.2014 * @since 1.0.0 */ namespace skeeks\cms\grid; use yii\grid\DataColumn; use yii\helpers\Html; /** * Class DateTimeColumnData * @package skeeks\cms\grid */ class DateTimeColumnData extends DataColumn { public $filter = false; public $headerOptions = [ 'style' => 'width: 130px;' ]; public $contentOptions = [ 'style' => 'width: 130px;' ]; const VIEW_RELITIVE_TYME = "VIEW_RELITIVE_TYME"; const VIEW_DATE = "VIEW_DATE"; public $view_type = self::VIEW_RELITIVE_TYME; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $timestamp = $model->{$this->attribute}; if (!$timestamp) { return ''; } if ($this->view_type == self::VIEW_RELITIVE_TYME) { return Html::tag("span", \Yii::$app->formatter->asRelativeTime($timestamp), [ 'title' => \Yii::$app->formatter->asDatetime($timestamp), 'data-toggle' => "tooltip" ]); } elseif ($this->view_type == self::VIEW_DATE) { return Html::tag("span", \Yii::$app->formatter->asDate($timestamp), [ 'title' => \Yii::$app->formatter->asDatetime($timestamp), 'data-toggle' => "tooltip" ]); } //return \Yii::$app->formatter->asDatetime($timestamp) . "<br /><small>" . \Yii::$app->formatter->asRelativeTime($timestamp) . "</small>"; } /** * @inheritdoc */ public function renderDataCellContentForExport($model, $key, $index) { if ($this->view_type == self::VIEW_RELITIVE_TYME) { $timestamp = $model->{$this->attribute}; return \Yii::$app->formatter->asDatetime($timestamp, "php:Y-m-d H:i:s"); } elseif ($this->view_type == self::VIEW_DATE) { $timestamp = $model->{$this->attribute}; return \Yii::$app->formatter->asDatetime($timestamp, "php:Y-m-d "); } //return \Yii::$app->formatter->asDatetime($timestamp) . "<br /><small>" . \Yii::$app->formatter->asRelativeTime($timestamp) . "</small>"; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/ImageColumn.php
src/grid/ImageColumn.php
<?php /** * ImageColumn * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 30.10.2014 * @since 1.0.0 */ namespace skeeks\cms\grid; /** * Class ImageColumn * @package skeeks\cms\grid */ class ImageColumn extends ImageColumn2 { }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/CreatedByColumn.php
src/grid/CreatedByColumn.php
<?php /** * CreatedByColumn * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 30.10.2014 * @since 1.0.0 */ namespace skeeks\cms\grid; /** * @deprecated * Class CreatedAtColumn * @package skeeks\cms\grid */ class CreatedByColumn extends UserColumnData { public $attribute = "created_by"; }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/GridViewPjaxTrait.php
src/grid/GridViewPjaxTrait.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 02.06.2015 */ namespace skeeks\cms\grid; use yii\helpers\ArrayHelper; use yii\widgets\Pjax; /** * Class GridViewSortableTrait * @package skeeks\cms\modules\admin\traits */ trait GridViewPjaxTrait { public $pjaxClassName = 'yii\widgets\Pjax'; /** * @var bool влючить/выключить pjax навигацию */ public $enabledPjax = true; /** * @var array */ public $pjaxOptions = []; /** * @var Pjax для того чтобы потом можно было обратиться к объекту pjax. */ public $pjax; protected $_pjaxCreated = false; public function pjaxBegin() { if ($this->enabledPjax) { if (!$this->pjax) { $this->_pjaxCreated = true; $pjaxClassName = $this->pjaxClassName; $this->pjax = $pjaxClassName::begin(ArrayHelper::merge([ 'id' => 'sx-pjax-grid-' . $this->id, ], $this->pjaxOptions)); } } } public function pjaxEnd() { if ($this->enabledPjax && $this->_pjaxCreated) { $pjaxClassName = $this->pjax->className(); $pjaxClassName::end(); } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/CheckboxColumn.php
src/grid/CheckboxColumn.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 24.07.2015 */ namespace skeeks\cms\grid; use yii\helpers\ArrayHelper; use yii\helpers\Json; /** * Class CheckboxColumn * @package skeeks\cms\grid */ class CheckboxColumn extends \yii\grid\CheckboxColumn { protected function renderHeaderCellContent() { $this->checkboxOptions = ArrayHelper::merge(['class' => 'sx-grid-checkbox'], $this->checkboxOptions); $id = $this->grid->options['id']; $jsOptions = [ 'gridId' => $id, ]; $jsOptionsString = Json::encode($jsOptions); $this->grid->getView()->registerJs(<<<JS (function(sx, $, _) { sx.classes.Checkbox = sx.classes.Component.extend({ _onDomReady: function() { $('.select-on-check-all').on('click', function() { _.delay(function() { $('.sx-grid-checkbox').each(function() { if ( $(this).is(":checked") ) { $(this).closest("tr").addClass("sx-active"); } else { $(this).closest("tr").removeClass("sx-active"); } }); }, 100); }); $("body").on('click', '.sx-grid-checkbox', function() { if ( $(this).is(":checked") ) { $(this).closest("tr").addClass("sx-active"); } else { $(this).closest("tr").removeClass("sx-active"); } }); } }); new sx.classes.Checkbox({$jsOptionsString}); })(sx, sx.$, sx._); JS ); return parent::renderHeaderCellContent(); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/ImageColumn2.php
src/grid/ImageColumn2.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 19.09.2015 */ namespace skeeks\cms\grid; use yii\grid\DataColumn; /** * Class ImageColumn2 * @package skeeks\cms\grid */ class ImageColumn2 extends DataColumn { public $filter = false; public $maxWidth = "50"; public $relationName = "image"; public $label = "Изображение"; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->relationName && $file = $model->{$this->relationName}) { $originalSrc = $file->src; $src = \Yii::$app->imaging->getImagingUrl($file->src, new \skeeks\cms\components\imaging\filters\Thumbnail()); } else { $src = \Yii::$app->cms->noImageUrl; $originalSrc = $src; } return "<a href='" . $originalSrc . "' class='sx-fancybox sx-img-link-hover' title='Увеличить' data-pjax='0'> <img src='" . $src . "' style='width: " . $this->maxWidth . "px;' /> </a>"; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/CmsContentElementColumn.php
src/grid/CmsContentElementColumn.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 05.08.2015 */ namespace skeeks\cms\grid; use skeeks\cms\helpers\UrlHelper; use skeeks\cms\models\CmsContentElement; use yii\grid\DataColumn; use yii\helpers\Html; /** * Class CmsContentElementColumn * @package skeeks\cms\grid */ class CmsContentElementColumn extends DataColumn { public $filter = false; public $attribute = "element_id"; public $relation = "element"; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { /** * @var $element CmsContentElement */ if ($this->relation) { $element = $model->{$this->relation}; if (!$element) { return null; } else { return Html::a($element->name . " [$element->id]", $element->url, [ 'target' => '_blank', 'data-pjax' => 0, 'title' => 'Посмотреть на сайте (откроется в новом окне)', ]) . " " . Html::a('<span class="fa fa-edit"></span>', UrlHelper::construct('/cms/admin-cms-content-element/update', [ 'content_id' => $element->content_id, 'pk' => $element->id, ]), [ 'data-pjax' => 0, 'class' => 'btn btn-xs btn-default', ]); } } return null; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/CreatedAtColumn.php
src/grid/CreatedAtColumn.php
<?php /** * CreatedAtColumn * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 30.10.2014 * @since 1.0.0 */ namespace skeeks\cms\grid; /** * @deprecated * @author Semenov Alexander <semenov@skeeks.com> */ class CreatedAtColumn extends DateTimeColumnData { public $attribute = "created_at"; }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/UserColumnData.php
src/grid/UserColumnData.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\grid; use skeeks\cms\helpers\UrlHelper; use skeeks\cms\models\User; use yii\grid\DataColumn; use yii\helpers\Html; /** * @author Semenov Alexander <semenov@skeeks.com> */ class UserColumnData extends DataColumn { public $headerOptions = [ 'style' => 'width: 150px;' ]; public $contentOptions = [ 'style' => 'width: 150px;' ]; /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $userId = (int)$model->{$this->attribute}; $user = User::findOne($userId); if ($user) { return \Yii::$app->view->render('@skeeks/cms/grid/views/user-column', [ 'user' => $user ]); } else { return null; } } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/grid/views/user-column.php
src/grid/views/user-column.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ /* @var $this yii\web\View */ /* @var $user \skeeks\cms\models\CmsUser */ ?> <? $widget = \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([ 'controllerId' => 'cms/admin-user', 'modelId' => $user->id, 'isRunFirstActionOnClick' => true ]); ?> <div class="d-flex flex-row"> <div class="my-auto" style="margin-right: 5px;"> <img src='<?= $user->avatarSrc ? $user->avatarSrc : \skeeks\cms\helpers\Image::getCapSrc(); ?>' style='max-width: 25px; max-height: 25px; border-radius: 50%;'/> </div> <div class="my-auto"> <div style="overflow: hidden; max-height: 40px; text-align: left;"> <?= $user->shortDisplayName; ?> </div> </div> </div> <? $widget::end(); ?>
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/sms/SmsHandler.php
src/sms/SmsHandler.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\sms; use skeeks\cms\IHasConfigForm; use skeeks\cms\models\CmsSmsMessage; use skeeks\cms\models\CmsSmsProvider; use skeeks\cms\shop\models\ShopOrder; use skeeks\cms\traits\HasComponentDescriptorTrait; use skeeks\cms\traits\TConfigForm; use yii\base\Exception; use yii\base\Model; use yii\widgets\ActiveForm; /** * @property Model $checkoutModel * * @author Semenov Alexander <semenov@skeeks.com> */ abstract class SmsHandler extends Model implements IHasConfigForm { use HasComponentDescriptorTrait; use TConfigForm; public function sendMessage(CmsSmsMessage $cmsSmsMessage) { $provider_message_id = $this->send($cmsSmsMessage->phone, $cmsSmsMessage->message); $cmsSmsMessage->provider_message_id = $provider_message_id; } /** * @param $phone * @param $text * @param null $sender * @return $message_id */ abstract public function send($phone, $text, $sender = null); /** * @param $message_id * @return mixed */ abstract public function status($message_id); /** * @return array */ public function senders() { return []; } /** * @return int */ public function balance() { return 0; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasName.php
src/traits/THasName.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\traits; use yii\helpers\ArrayHelper; /** * @property $name; * * @author Semenov Alexander <semenov@skeeks.com> */ trait THasName { /** * @var string */ protected $_name = ''; /** * @return string|bool */ public function getName() { return $this->_name; } /** * @param string|array|bool $name * @return $this */ public function setName($name) { if (is_array($name)) { $this->_name = \Yii::t( ArrayHelper::getValue($name, 0), ArrayHelper::getValue($name, 1, ''), ArrayHelper::getValue($name, 2, []), ArrayHelper::getValue($name, 3) ); } else if (is_string($name)) { $this->_name = $name; } else if (is_bool($name)) { $this->_name = $name; } else if (is_null($name)) { $this->_name = false; } return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasIcon.php
src/traits/THasIcon.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\traits; /** * @property $icon; * * @author Semenov Alexander <semenov@skeeks.com> */ trait THasIcon { /** * @var string */ protected $_icon = ''; /** * @return string */ public function getIcon() { return $this->_icon; } /** * @param $icon * @return $this */ public function setIcon($icon) { $this->_icon = $icon; return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasUrl.php
src/traits/THasUrl.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright 2010 SkeekS * @date 05.03.2017 */ namespace skeeks\cms\traits; use yii\helpers\Url; /** * @property string $url; * @property string|array $urlData; * * Class THasUrl * @package skeeks\cms\traits */ trait THasUrl { /** * @var string|array */ protected $_url = null; /** * @return string */ public function getUrl() { if (is_array($this->_url)) { return Url::to($this->_url); } return (string)$this->_url; } /** * @param string|array $url * @return $this */ public function setUrl($url) { if (!is_array($url)) { \Yii::warning('bad url ' . $url, 'adminUrl'); } $this->_url = $url; return $this; } /** * @return array|string|null */ public function getUrlData() { return $this->_url; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/HasComponentDescriptorTrait.php
src/traits/HasComponentDescriptorTrait.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 20.05.2015 */ namespace skeeks\cms\traits; use skeeks\cms\assets\CmsAsset; use skeeks\cms\base\ComponentDescriptor; /** * * @property ComponentDescriptor descriptor * * Class HasComponentDescriptorTrait * @package skeeks\cms\traits */ trait HasComponentDescriptorTrait { /** * @var ComponentDescriptor */ protected $_descriptor = null; /** * @var string */ static public $descriptorClassName = 'skeeks\cms\base\ComponentDescriptor'; /** * @return array */ public static function descriptorConfig() { return [ "name" => "Skeeks CMS", "image" => [CmsAsset::class, 'img/image-not-found.jpg'], "description" => "", "keywords" => "skeeks, cms", ]; } /** * @return ComponentDescriptor */ public function getDescriptor() { if ($this->_descriptor === null) { $classDescriptor = static::$descriptorClassName; if (class_exists($classDescriptor)) { $this->_descriptor = new $classDescriptor(static::descriptorConfig()); } else { $this->_descriptor = new ComponentDescriptor(static::descriptorConfig()); } } return $this->_descriptor; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/TActiveRecord.php
src/traits/TActiveRecord.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\traits; /** * @property string $asText; * @property string $asHtml; * * @author Semenov Alexander <semenov@skeeks.com> */ trait TActiveRecord { /** * @return string */ public function __toString() { return $this->asText(); } /** * @return string */ public function asText() { $result = []; //$result[] = "#".$this->id; if (isset($this->name) && is_string($this->name)) { $result[] = $this->name; } else if (isset($this->label) && is_string($this->label)) { $result[] = $this->label; } else if (isset($this->id)) { $result[] = $this->id; } return implode("#", $result); } /** * @return string */ public function getAsText() { return $this->asText(); } /** * @return string */ public function getAsHtml() { return $this->asHtml(); } /** * @return string */ public function asHtml() { return $this->asText(); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasPermission.php
src/traits/THasPermission.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright 2010 SkeekS * @date 05.03.2017 */ namespace skeeks\cms\traits; use skeeks\cms\rbac\CmsManager; use yii\base\InvalidConfigException; use yii\web\Application; /** * @property string|null $permissionName; * * Trait THasPermissions * @package skeeks\cms\traits */ trait THasPermission { /** * @var string * @deprecated */ protected $_permissionName = null; /** * @return string * @deprecated */ public function getPermissionName() { return $this->_permissionName; } /** * @param string|null $permissionName * @return $this * @deprecated */ public function setPermissionName($permissionName = null) { $this->_permissionName = $permissionName; return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasModel.php
src/traits/THasModel.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright 2010 SkeekS * @date 05.03.2017 */ namespace skeeks\cms\traits; use yii\base\Model; /** * @property Model $model; * * Class THasModel * @package skeeks\cms\traits */ trait THasModel { /** * @var string */ protected $_model = ''; /** * @return string */ public function getModel() { return $this->_model; } /** * @param Model $model * @return $this */ public function setModel($model) { $this->_model = $model; return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasPermissions.php
src/traits/THasPermissions.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright 2010 SkeekS * @date 05.03.2017 */ namespace skeeks\cms\traits; use skeeks\cms\rbac\CmsManager; use yii\base\InvalidConfigException; use yii\web\Application; /** * @property callable|null $accessCallback; * @property array|null $permissionNames; * @property bool $isAllow; * * Class THasPermissions * @package skeeks\cms\traits */ trait THasPermissions { /** * @var array */ protected $_permissionNames = null; /** * @return array */ public function getPermissionNames() { return $this->_permissionNames; } /** * @param array $permissionNames * @return $this */ public function setPermissionNames(array $permissionNames = null) { $this->_permissionNames = $permissionNames; return $this; } /** * @var callable|null|boolean */ protected $_accessCallback = null; /** * @return callable|null|boolean */ public function getAccessCallback() { return $this->_accessCallback; } /** * @param null|callable|boolean $accessCallback * * @return $this */ public function setAccessCallback($accessCallback = null) { if ($accessCallback !== null && !is_callable($accessCallback) && !is_bool($accessCallback)) { throw new InvalidConfigException('accessCallback must be callable or null or boolean'); } $this->_accessCallback = $accessCallback; return $this; } /** * @return bool */ public function getIsAllow() { //Если указаны привелегии для проверки, то нужно их проверить, если нет доступа к ним дальше нет смысла проверять. if ($this->permissionNames) { if (!$this->_isAllowPermissions()) { return false; } } if ($this->accessCallback && is_callable($this->accessCallback)) { $callback = $this->accessCallback; return (bool)call_user_func($callback, $this); } if ($this->accessCallback && is_bool($this->accessCallback)) { return (bool)$this->accessCallback; } return $this->_isAllow(); } /** * @return bool */ protected function _isAllow() { return true; } /** * @return bool * @throws \yii\base\Exception */ protected function _isAllowPermissions() { if ($this->permissionNames) { foreach ($this->permissionNames as $permissionName => $permissionLabel) { //Привилегия доступу к админке if (!$permission = \Yii::$app->authManager->getPermission($permissionName)) { $permission = \Yii::$app->authManager->createPermission($permissionName); $permission->description = $permissionLabel; \Yii::$app->authManager->add($permission); //После первого создания назначение администратору if ($roleAdmin = \Yii::$app->authManager->getRole(CmsManager::ROLE_ADMIN)) { if (!\Yii::$app->authManager->hasChild($roleAdmin, $permission)) { \Yii::$app->authManager->addChild($roleAdmin, $permission); } } } if ($roleRoot = \Yii::$app->authManager->getRole(CmsManager::ROLE_ROOT)) { if (!\Yii::$app->authManager->hasChild($roleRoot, $permission)) { \Yii::$app->authManager->addChild($roleRoot, $permission); } } if (\Yii::$app instanceof Application && !\Yii::$app->user->can($permissionName)) { return false; } } } return true; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/TConfigForm.php
src/traits/TConfigForm.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\traits; use yii\widgets\ActiveForm; /** * @author Semenov Alexander <semenov@skeeks.com> */ trait TConfigForm { /** * @return ActiveForm */ public function beginConfigForm() { return ActiveForm::begin(); } /** * @return array */ public function getConfigFormFields() { return []; } /** * @var string */ /*public $configFormView = "";*/ /** * * @param ActiveForm $form * @return string */ public function renderConfigFormFields(ActiveForm $form) { $formContent = ''; if ($fields = $this->getConfigFormFields()) { $formContent = (new \skeeks\yii2\form\Builder([ 'models' => $this->getConfigFormModels(), 'model' => $this, 'activeForm' => $form, 'fields' => $fields, ]))->render(); } else { /*if ($this->configFormView) { $formContent = \Yii::$app->view->render($this->configFormView, [ 'model' => $this, 'form' => $form, ]); }*/ } return $formContent; } /** * @return array */ public function getConfigFormModels() { return []; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasImage.php
src/traits/THasImage.php
<?php /** * @link https://cms.skeeks.com/ * @copyright Copyright (c) 2010 SkeekS * @license https://cms.skeeks.com/license/ * @author Semenov Alexander <semenov@skeeks.com> */ namespace skeeks\cms\traits; /** * @property $image; * * @author Semenov Alexander <semenov@skeeks.com> */ trait THasImage { /** * @var string */ protected $_image = ''; /** * @return string * @throws \yii\base\InvalidConfigException */ public function getImage() { if ($this->_image === null) { return ""; } if (is_array($this->_image) && count($this->_image) == 2) { list($assetClassName, $localPath) = $this->_image; return (string)\Yii::$app->getAssetManager()->getAssetUrl(\Yii::$app->assetManager->getBundle($assetClassName), $localPath); } if (is_string($this->_image)) { return $this->_image; } return ""; } /** * @param $image * @return $this */ public function setImage($image) { $this->_image = $image; return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/TWidget.php
src/traits/TWidget.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 22.05.2015 */ namespace skeeks\cms\traits; use ReflectionClass; use Yii; use yii\base\Widget; use yii\base\WidgetEvent; /** * Оригинальный yii\base\Widget * Взят из yii 2.0.4 * @see yii\base\Widget * * Class WidgetTrait * @package skeeks\cms\traits */ trait TWidget { /** * @var integer a counter used to generate [[id]] for widgets. * @internal */ public static $counter = 0; /** * @var string the prefix to the automatically generated widget IDs. * @see getId() */ public static $autoIdPrefix = 'skeeks'; /** * @var Widget[] the widgets that are currently being rendered (not ended). This property * is maintained by [[begin()]] and [[end()]] methods. * @internal */ public static $stack = []; /** * Begins a widget. * This method creates an instance of the calling class. It will apply the configuration * to the created instance. A matching [[end()]] call should be called later. * As some widgets may use output buffering, the [[end()]] call should be made in the same view * to avoid breaking the nesting of output buffers. * @param array $config name-value pairs that will be used to initialize the object properties * @return static the newly created widget instance * @see end() */ public static function begin($config = []) { $config['class'] = get_called_class(); /* @var $widget Widget */ $widget = Yii::createObject($config); self::$stack[] = $widget; return $widget; } /** * Ends a widget. * Note that the rendering result of the widget is directly echoed out. * @return static the widget instance that is ended. * @throws InvalidCallException if [[begin()]] and [[end()]] calls are not properly nested * @see begin() */ public static function end() { if (!empty(self::$stack)) { $widget = array_pop(self::$stack); if (get_class($widget) === get_called_class()) { /* @var $widget Widget */ if ($widget->beforeRun()) { $result = $widget->run(); $result = $widget->afterRun($result); echo $result; } return $widget; } throw new InvalidCallException('Expecting end() of ' . get_class($widget) . ', found ' . get_called_class()); } throw new InvalidCallException('Unexpected ' . get_called_class() . '::end() call. A matching begin() is not found.'); } /** * Creates a widget instance and runs it. * The widget rendering result is returned by this method. * @param array $config name-value pairs that will be used to initialize the object properties * @return string the rendering result of the widget. * @throws \Exception */ public static function widget($config = []) { ob_start(); ob_implicit_flush(false); try { /* @var $widget Widget */ $config['class'] = get_called_class(); $widget = Yii::createObject($config); $out = ''; if ($widget->beforeRun()) { $result = $widget->run(); $out = $widget->afterRun($result); } } catch (\Exception $e) { // close the output buffer opened above if it has not been closed already if (ob_get_level() > 0) { ob_end_clean(); } throw $e; } return ob_get_clean() . $out; } private $_id; /** * Returns the ID of the widget. * @param boolean $autoGenerate whether to generate an ID if it is not set previously * @return string ID of the widget. */ public function getId($autoGenerate = true) { if ($autoGenerate && $this->_id === null) { $this->_id = static::$autoIdPrefix.static::$counter++; } return $this->_id; } /** * Sets the ID of the widget. * @param string $value id of the widget. */ public function setId($value) { $this->_id = $value; } private $_view; /** * Returns the view object that can be used to render views or view files. * The [[render()]] and [[renderFile()]] methods will use * this view object to implement the actual view rendering. * If not set, it will default to the "view" application component. * @return \yii\web\View the view object that can be used to render views or view files. */ public function getView() { if ($this->_view === null) { $this->_view = Yii::$app->getView(); } return $this->_view; } /** * Sets the view object to be used by this widget. * @param View $view the view object that can be used to render views or view files. */ public function setView($view) { $this->_view = $view; } /** * Executes the widget. * @return string the result of widget execution to be outputted. */ public function run() { } /** * Renders a view. * The view to be rendered can be specified in one of the following formats: * * - path alias (e.g. "@app/views/site/index"); * - absolute path within application (e.g. "//site/index"): the view name starts with double slashes. * The actual view file will be looked for under the [[Application::viewPath|view path]] of the application. * - absolute path within module (e.g. "/site/index"): the view name starts with a single slash. * The actual view file will be looked for under the [[Module::viewPath|view path]] of the currently * active module. * - relative path (e.g. "index"): the actual view file will be looked for under [[viewPath]]. * * If the view name does not contain a file extension, it will use the default one `.php`. * * @param string $view the view name. * @param array $params the parameters (name-value pairs) that should be made available in the view. * @return string the rendering result. * @throws InvalidParamException if the view file does not exist. */ public function render($view, $params = []) { return $this->getView()->render($view, $params, $this); } /** * Renders a view file. * @param string $file the view file to be rendered. This can be either a file path or a path alias. * @param array $params the parameters (name-value pairs) that should be made available in the view. * @return string the rendering result. * @throws InvalidParamException if the view file does not exist. */ public function renderFile($file, $params = []) { return $this->getView()->renderFile($file, $params, $this); } /** * Returns the directory containing the view files for this widget. * The default implementation returns the 'views' subdirectory under the directory containing the widget class file. * @return string the directory containing the view files for this widget. */ public function getViewPath() { $class = new ReflectionClass($this); return dirname($class->getFileName()).DIRECTORY_SEPARATOR.'views'; } /** * This method is invoked right before the widget is executed. * * The method will trigger the [[EVENT_BEFORE_RUN]] event. The return value of the method * will determine whether the widget should continue to run. * * When overriding this method, make sure you call the parent implementation like the following: * * ```php * public function beforeRun() * { * if (!parent::beforeRun()) { * return false; * } * * // your custom code here * * return true; // or false to not run the widget * } * ``` * * @return bool whether the widget should continue to be executed. * @since 2.0.11 */ public function beforeRun() { $event = new WidgetEvent(); $this->trigger(Widget::EVENT_BEFORE_RUN, $event); return $event->isValid; } /** * This method is invoked right after a widget is executed. * * The method will trigger the [[EVENT_AFTER_RUN]] event. The return value of the method * will be used as the widget return value. * * If you override this method, your code should look like the following: * * ```php * public function afterRun($result) * { * $result = parent::afterRun($result); * // your custom code here * return $result; * } * ``` * * @param mixed $result the widget return result. * @return mixed the processed widget result. * @since 2.0.11 */ public function afterRun($result) { $event = new WidgetEvent(); $event->result = $result; $this->trigger(Widget::EVENT_AFTER_RUN, $event); return $event->result; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/ActiveFormAjaxSubmitTrait.php
src/traits/ActiveFormAjaxSubmitTrait.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 19.05.2015 */ namespace skeeks\cms\traits; use skeeks\cms\assets\ActiveFormAjaxSubmitAsset; use yii\helpers\Html; use yii\helpers\Inflector; /** * * <? $form = \skeeks\cms\base\widgets\ActiveFormAjaxSubmit::begin([ 'clientCallback' => new \yii\web\JsExpression(<<<JS function (ActiveFormAjaxSubmit) { ActiveFormAjaxSubmit.on('success', function(e, response) { $("#sx-result").empty(); if (response.data.html) { $("#sx-result").append(response.data.html); } }); } JS ) ]); ?> * * Trait ActiveFormAjaxSubmitTrait * @package skeeks\cms\traits */ trait ActiveFormAjaxSubmitTrait { /** * @var null */ public $clientCallback = null; /** * @deprecated * @var string */ public $afterValidateCallback = ""; /** * @var bool */ public $enableClientValidation = true; /** * @var bool */ public $enableAjaxValidation = false; public function registerJs() { ActiveFormAjaxSubmitAsset::register($this->view); $this->view->registerJs(<<<JS sx.ActiveForm = new sx.classes.activeForm.AjaxSubmit('{$this->id}'); /*sx.ActiveForm.jForm.off('mouseup.yiiActiveForm keyup.yiiActiveForm');*/ JS ); $afterValidateCallback = $this->afterValidateCallback; $clientCallback = $this->clientCallback; if ($clientCallback) { $id = Inflector::id2camel($this->id); $this->view->registerJs(<<<JS var callback{$id} = $clientCallback; callback{$id}(sx.ActiveForm); JS ); } elseif ($afterValidateCallback) { $this->view->registerJs(<<<JS sx.ActiveForm.on('afterValidate', function(e, data) { var callback = $afterValidateCallback; var ActiveForm = data.activeFormAjaxSubmit; callback(ActiveForm.jForm, ActiveForm.AjaxQuery); }); JS ); } } public function run() { $this->registerJs(); return parent::run(); } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/traits/THasInfo.php
src/traits/THasInfo.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link https://skeeks.com/ * @copyright 2010 SkeekS * @date 05.03.2017 */ namespace skeeks\cms\traits; use yii\helpers\ArrayHelper; /** * @deprecated * * @property $name; * @property $icon; * @property $image; */ trait THasInfo { /** * @var string */ protected $_name = ''; /** * @return string */ public function getName() { return $this->_name; } /** * @param string|array $name * @return $this */ public function setName($name) { if (is_array($name)) { $this->_name = \Yii::t( ArrayHelper::getValue($name, 0), ArrayHelper::getValue($name, 1, ''), ArrayHelper::getValue($name, 2, []), ArrayHelper::getValue($name, 3) ); } else if (is_string($name)) { $this->_name = $name; } return $this; } /** * @var string */ protected $_icon = ''; /** * @return string */ public function getIcon() { return $this->_icon; } /** * @param $icon * @return $this */ public function setIcon($icon) { $this->_icon = $icon; return $this; } /** * @var string */ protected $_image = ''; /** * @return string */ public function getImage() { return $this->_image; } /** * @param $image * @return $this */ public function setImage($image) { $this->_image = $image; return $this; } }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/web/View.php
src/web/View.php
<?php /** * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 27.03.2015 */ namespace skeeks\cms\web; use skeeks\cms\base\Theme; use skeeks\cms\models\CmsSite; use skeeks\cms\models\CmsSiteTheme; use skeeks\cms\models\CmsTheme; use yii\caching\TagDependency; use yii\helpers\ArrayHelper; use yii\web\Application; /** * @property array $availableThemes * * @author Semenov Alexander <semenov@skeeks.com> */ class View extends \yii\web\View { /** * @var string */ public $defaultThemeId = ''; /** * Принудительно включить эту тему * Нужно например для разработки, можно включить окружение и в нем прописать использование нужного шаблона * Тогда для всех пользователей будет использован 1 шаблон, а для разработчика свой шаблон * @var string */ public $forceThemeId = ''; /** * @var array Доступные темы */ public $themes = [ /*'one' => [ 'class' => 'skeeks\cms\view\ThemeComponent', 'sites' => [ 1, 20 ], ]*/ ]; /** * @var null */ protected $_availableThemes = null; /** * @return array */ public function getAvailableThemes(CmsSite $site = null) { if ($this->_availableThemes === null) { if ($site === null) { $site = \Yii::$app->skeeks->site; } $result = []; foreach ($this->themes as $id => $themeData) { //Если тема доступна не для всех сайтов $siteIds = (array) ArrayHelper::getValue($themeData, 'site_ids'); if ($siteIds) { //Если для текущего сайта шаблон недоступен, то пропускаем его if (!in_array($site->id, $siteIds)) { continue; } } $result[$id] = $themeData; } $this->_availableThemes = $result; } return $this->_availableThemes; } /** * @param $themes * @return $this */ public function setAvailableThemes($themes = []) { $this->_availableThemes = $themes; return $this; } /** * @return void */ public function init() { if (!$this->availableThemes) { return parent::init(); } if ($this->forceThemeId) { $cmsTheme = CmsTheme::getDb()->cache(function ($db) { return CmsTheme::find()->cmsSite()->andWhere(['code' => $this->forceThemeId])->one(); }, null, new TagDependency([ 'tags' => [ (new CmsTheme())->getTableCacheTagCmsSite(), \Yii::$app->skeeks->site->cacheTag ], ]) ); } else { //Поиск настроек сохраненных в базу данных $cmsTheme = CmsTheme::getDb()->cache(function ($db) { return CmsTheme::find()->cmsSite()->active()->one(); }, null, new TagDependency([ 'tags' => [ (new CmsTheme())->getTableCacheTagCmsSite(), \Yii::$app->skeeks->site->cacheTag ], ]) ); } $themeData = []; if ($cmsTheme) { //Бурется настройки из конфига /** * @var $cmsTheme CmsTheme */ $themeData = (array)ArrayHelper::getValue($this->availableThemes, $cmsTheme->code); //$themeData = ArrayHelper::merge($themeData, (array) $cmsTheme->config); //print_r($themeData);die; } else { if ($this->forceThemeId) { $themeData = (array)ArrayHelper::getValue($this->availableThemes, $this->forceThemeId); } else if ($this->defaultThemeId) { $themeData = (array)ArrayHelper::getValue($this->availableThemes, $this->defaultThemeId); } } if ($themeData) { $this->theme = $themeData; } //Тут создание объекта тему parent::init(); //Из настроек сайта выбралась тема $defaultSelectTheme = $this->theme; //Перед рендером темы, нужно проверить та ли тема сейчас установлена? //Она могла переопределиться в процессе \Yii::$app->on(Application::EVENT_BEFORE_ACTION, function ($event) use ($cmsTheme, $defaultSelectTheme) { if (\Yii::$app->controller && \Yii::$app->controller->module && in_array(\Yii::$app->controller->module->id, ['debug', 'gii'])) { return false; } if ($this->theme instanceof $defaultSelectTheme) { //Если тема та, то нужно установить настройки в тему из базы данных if ($cmsTheme) { $cmsTheme->loadConfigToTheme($this->theme); $this->theme->trigger(static::EVENT_BEFORE_RENDER, $event); } } }); } /** * @return string */ /*public function getCurrentThemeId() { $cmsTheme = CmsTheme::find()->cmsSite()->active()->one(); if ($cmsTheme) { return (string) $cmsTheme->code; } return $this->defaultThemeId; }*/ }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/_ide/UserIde.php
_ide/UserIde.php
<?php /** * Псевдо класс только для подсказок IDE * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 02.07.2015 */ namespace skeeks\cms\_ide; /** * @property \yii\web\IdentityInterface|\skeeks\cms\models\User|\common\models\User $identity * * Class UserIde * @package skeeks\cms\_ide */ class UserIde extends \yii\web\User { }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
skeeks-cms/cms
https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/_ide/YiiApplication.php
_ide/YiiApplication.php
<?php /** * The pseudo-only IDE tips * * @author Semenov Alexander <semenov@skeeks.com> * @link http://skeeks.com/ * @copyright 2010-2014 SkeekS (Sx) * @date 12.11.2014 * @since 1.0.0 */ namespace yii\web; use skeeks\cms\_ide\UserIde; use skeeks\cms\components\Adult; use skeeks\cms\components\Breadcrumbs; use skeeks\cms\components\Cms; use skeeks\cms\components\CmsToolbar; use skeeks\cms\components\ConsoleComponent; use skeeks\cms\components\Imaging; use skeeks\cms\components\LegalComponent; use skeeks\cms\components\storage\Storage; use skeeks\cms\i18n\I18N; use skeeks\cms\Skeeks; /** * @property Storage $storage * @property Cms $cms * @property LegalComponent $legal * @property Imaging $imaging * @property Breadcrumbs $breadcrumbs * @property Skeeks $skeeks * @property ConsoleComponent $console * @property I18N $i18n * @property \skeeks\cms\web\View $view * @property Adult $adult * * @property \yii\web\User|UserIde|\skeeks\cms\components\User $user * * Class Application * @package yii\web */ class Application { }
php
BSD-3-Clause
c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf
2026-01-05T04:50:22.405425Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Theme.php
src/Theme.php
<?php namespace Facuz\Theme; use Closure; use ReflectionClass; use Illuminate\Http\Response; use Illuminate\View\Factory; use Illuminate\Config\Repository; use Illuminate\Events\Dispatcher; use Illuminate\Filesystem\Filesystem; use Illuminate\View\Compilers\BladeCompiler; use Illuminate\Database\Eloquent\Collection; use Symfony\Component\HttpFoundation\Cookie; use Facuz\Theme\Contracts\Theme as ThemeContract; use Facuz\Theme\Manifest; use Illuminate\Support\Arr; class Theme implements ThemeContract { /** * Theme namespace. */ public static $namespace = 'theme'; /** * Repository config. * * @var \Illuminate\Config\Repository */ protected $config; /** * Manifest. * * @var \Facuz\Theme\Manifest */ protected $manifest; /** * Event dispatcher. * * @var \Illuminate\Events\Dispatcher */ protected $events; /** * Theme configuration. * * @var mixed */ protected $themeConfig; /** * View. * * @var \Illuminate\View\Factory */ protected $view; /** * Asset. * * @var \Facuz\Assets */ protected $asset; /** * Filesystem. * * @var \Illuminate\Filesystem\Filesystem */ protected $files; /** * Breadcrumb. * * @var \Facuz\Breadcrumb */ protected $breadcrumb; /** * The name of theme. * * @var string */ protected $theme; /** * The name of layout. * * @var string */ protected $layout; /** * Content dot path. * * @var string */ protected $content; /** * Path of all themes. * * @var array */ protected $themesPath; /** * Regions in the theme. * * @var array */ protected $regions = array(); /** * Content arguments. * * @var array */ protected $arguments = array(); /** * Injected arguments. * * @var array */ protected $argInjected = array(); /** * Data bindings. * * @var array */ protected $bindings = array(); /** * Cookie var. * * @var Cookie */ protected $cookie; /** * Engine compiler. * * @var array */ protected $compilers = array(); /** * Create a new theme instance. * * @param \Illuminate\Config\Repository $config * @param \Illuminate\Events\Dispatcher $events * @param \Illuminate\View\Factory $view | * @param \Facuz\Theme\asset $asset * @param \Illuminate\Filesystem\Filesystem $files * @param \Facuz\Breadcrumb|\Facuz\Theme\Breadcrumb $breadcrumb * @param \Facuz\Theme\Manifest $manifest * * @return \Facuz\Theme\Theme */ public function __construct(Repository $config, Dispatcher $events, Factory $view, Asset $asset, Filesystem $files, Breadcrumb $breadcrumb, Manifest $manifest) { $this->config = $config; $this->manifest = $manifest; $this->events = $events; $this->view = $view; $this->asset = $asset; $this->files = $files; $this->breadcrumb = $breadcrumb; //$this->theme = $this->getConfig('themeDefault'); $this->theme($this->getConfig('themeDefault')); //$this->layout = $this->getConfig('layoutDefault'); $this->layout($this->getConfig('layoutDefault')); $this->compilers['blade'] = new BladeCompiler($files, 'theme'); $this->themesPath = base_path($this->path("")); } /** * Compile the inject statements into valid PHP. * * @param string $variable * @param string $service * @return string */ public function inject($variable, $service) { $this->argInjected[$variable] = app($service); /* var_dump("<?php \${$variable} = app('{$service}'); ?>"); */ } /** * Get a view * * @return View */ public function view($view, $args = []){ if(is_array($view)) { if(isset($view['theme'])) $this->theme($view['theme']); if(isset($view['layout'])) $this->layout($view['layout']); if(isset($view['cookie'])) $this->withCookie($view['cookie']); $statusCode = (isset($view['statusCode'])) ? $view['statusCode'] : 200; if(empty($args)) if(isset($view['args'])) $args = $view['args']; $view = $view['view']; } $this->uses($this->theme)->layout($this->layout); return $this->watch($view, $args)->render(); } /** * Get or set data on manifest. * * @return Collection */ public function info($property = null, $value = null) { $info = $this->manifest; $info->setThemePath($this->getThemePath()); if($value && $property){ $info->setProperty($property, $value); return $value; } else { if($property){ return $info->getProperty($property); } return $info->getJsonContents(); } } /** * Get all themes. * * @return Collection */ public function all() { $themes = []; if ($this->files->exists($this->getThemePath().'../')) { $scannedThemes = $this->files->directories($this->getThemePath().'../'); foreach ($scannedThemes as $theme) { $themes[] = basename($theme); } } return new Collection($themes); } /** * Get current theme name. * * @return string */ public function getThemeName() { return $this->theme; } /** * Get current layout name. * * @return string */ public function getLayoutName() { return $this->layout; } /** * Get theme namespace. * * @param string $path * * @return string */ public function getThemeNamespace($path = '') { // Namespace relate with the theme name. $namespace = static::$namespace.'.'.$this->getThemeName(); if ($path != false) { return $namespace.'::'.$path; } return $namespace; } /** * Check theme exists. * * @param string $theme * @return boolean */ public function exists($theme) { $path = base_path($this->path($theme)).'/'; return is_dir($path); } /** * Link to another view. * * <code> * // Look up view from another view in the same place. * Theme::symlink('another') * </code> * * @param string $theme * @return string */ public function symlink($theme) { $trace = debug_backtrace(); if (! isset($trace[1])) return; $link = str_replace($this->getThemeName(), $theme, Arr::get($trace[1], 'file')); extract($this->arguments); extract($this->view->getShared()); return require($link); } /** * Symlink with inherit. * * This method is the same symlink, but try to find inherit, * from config. * * @param string $theme * @return string */ public function symlinkWithFindInherit($theme) { $trace = debug_backtrace(); if (! isset($trace[1])) return; // change backslash to forward slash (for windows file system) $path = str_replace("\\", "/", Arr::get($trace[1], 'file')); $config = $this->getConfig(); $link = preg_replace("#({$config['themeDir']}/)[^/]+#", "$1{$theme}", $path); extract($this->arguments); extract($this->view->getShared()); return require($link); } /** * Get theme config. * * @param string $key * @return mixed */ public function getConfig($key = null) { // Main package config. if (!$this->themeConfig) { $this->themeConfig = $this->config->get('theme'); } // Config inside a public theme. // This config having buffer by array object. if ($this->theme and ! isset($this->themeConfig['themes'][$this->theme])) { $this->themeConfig['themes'][$this->theme] = array(); try { // Require public theme config. $minorConfigPath = base_path($this->themeConfig['themeDir'].'/'.$this->theme.'/config.php'); $this->themeConfig['themes'][$this->theme] = $this->files->getRequire($minorConfigPath); } catch (\Illuminate\Filesystem\FileNotFoundException $e) { //var_dump($e->getMessage()); } } // Evaluate theme config. $this->themeConfig = $this->evaluateConfig($this->themeConfig); return is_null($key) ? $this->themeConfig : \Arr::get($this->themeConfig, $key); } /** * Evaluate config. * * Config minor is at public folder [theme]/config.php, * thet can be override package config. * * @param mixed $config * @return mixed */ protected function evaluateConfig($config) { if (! isset($config['themes'][$this->theme])) { return $config; } // Config inside a public theme. $minorConfig = $config['themes'][$this->theme]; // Before event is special case, It's combination. if (isset($minorConfig['events']['before'])) { $minorConfig['events']['appendBefore'] = $minorConfig['events']['before']; unset($minorConfig['events']['before']); } // Merge two config into one. $config = array_replace_recursive($config, $minorConfig); // Reset theme config. $config['themes'][$this->theme] = array(); return $config; } /** * Add location path to look up. * * @param string $location */ protected function addPathLocation($location) { // First path is in the selected theme. $hints[] = base_path($location); // This is nice feature to use inherit from another. if ($this->getConfig('inherit')) { // Inherit from theme name. $inherit = $this->getConfig('inherit'); // Inherit theme path. $inheritPath = base_path($this->path($inherit)); if ($this->files->isDirectory($inheritPath)) { array_push($hints, $inheritPath); } } // Add namespace with hinting paths. $this->view->addNamespace($this->getThemeNamespace(), $hints); } /** * Fire event to config listener. * * @param string $event * @param mixed $args * @return void */ public function fire($event, $args) { $onEvent = $this->getConfig('events.'.$event); if ($onEvent instanceof Closure) { $onEvent($args); } } /** * Set up a theme name. * * @param string $theme * @throws UnknownThemeException * @return Theme */ public function theme($theme = null) { // If theme name is not set, so use default from config. if ($theme != false) { $this->theme = $theme; } // Is theme ready? if (!$this->exists($theme)) { throw new UnknownThemeException("Theme [$theme] not found."); } // Add location to look up view. $this->addPathLocation($this->path()); // Fire event before set up a theme. $this->fire('before', $this); // Before from a public theme config. $this->fire('appendBefore', $this); // Add asset path to asset container. $this->asset->addPath($this->path().'/assets'); return $this; } /** * Alias of theme method. * * @param string $theme * @return Theme */ public function uses($theme = null) { return $this->theme($theme); } /** * Set up a layout name. * * @param string $layout * @return Theme */ public function layout($layout) { // If layout name is not set, so use default from config. if ($layout != false) { $this->layout = $layout; } return $this; } /** * Get theme path. * * @param string $forceThemeName * @return string */ public function path($forceThemeName = null) { $themeDir = $this->getConfig('themeDir'); $theme = $this->theme; if ($forceThemeName != false) { $theme = $forceThemeName; } return $themeDir.'/'.$theme; } /** * Get theme path. * * @return Collection */ public function getThemePath() { return base_path($this->path($this->theme)).'/'; } /** * Set a place to regions. * * @param string $region * @param string $value * @return Theme */ public function set($region, $value) { // Content is reserve region for render sub-view. if ($region == 'content') return; $this->regions[$region] = $value; return $this; } /** * Append a place to existing region. * * @param string $region * @param string $value * @return Theme */ public function append($region, $value) { return $this->appendOrPrepend($region, $value, 'append'); } /** * Prepend a place to existing region. * * @param string $region * @param string $value * @return Theme */ public function prepend($region, $value) { return $this->appendOrPrepend($region, $value, 'prepend'); } /** * Append or prepend existing region. * * @param string $region * @param string $value * @param string $type * @return Theme */ protected function appendOrPrepend($region, $value, $type = 'append') { // If region not found, create a new region. if (isset($this->regions[$region])) { switch ($type) { case 'prepend' : $this->regions[$region] = $value.$this->regions[$region]; break; case 'append' : $this->regions[$region] .= $value; break; } } else { $this->set($region, $value); } return $this; } /** * Binding data to view. * * @param string $variable * @param mixed $callback * @return mixed */ public function bind($variable, $callback = null) { $name = 'bind.'.$variable; // If callback pass, so put in a queue. if (! empty($callback)) { // Preparing callback in to queues. $this->events->listen($name, function() use ($callback, $variable) { return ($callback instanceof Closure) ? $callback() : $callback; }); } // Passing variable to closure. $_events =& $this->events; $_bindings =& $this->bindings; // Buffer processes to save request. return Arr::get($this->bindings, $name, function() use (&$_events, &$_bindings, $name) { $response = current($_events->fire($name)); array_set($_bindings, $name, $response); return $response; }); } /** * Check having binded data. * * @param string $variable * @return boolean */ public function binded($variable) { $name = 'bind.'.$variable; return $this->events->hasListeners($name); } /** * Assign data across all views. * * @param mixed $key * @param mixed $value * @return mixed */ public function share($key, $value) { return $this->view->share($key, $value); } /** * Set up a partial. * * @param string $view * @param array $args * @throws UnknownPartialFileException * @return mixed */ public function partial($view, $args = array()) { $partialDir = $this->getThemeNamespace('partials'); return $this->loadPartial($view, $partialDir, $args); } /** * The same as "partial", but having prefix layout. * * @param string $view * @param array $args * @throws UnknownPartialFileException * @return mixed */ public function partialWithLayout($view, $args = array()) { $view = $this->getLayoutName().'.'.$view; return $this->partial($view, $args); } /** * Load a partial * * @param string $view * @param string $partialDir * @param array $args * @throws UnknownPartialFileException * @return mixed */ public function loadPartial($view, $partialDir, $args) { $path = $partialDir.'.'.$view; if (! $this->view->exists($path)) { $fallback = config('theme.view_fallback', ''); if (!empty($fallback)) { $path = "$fallback.partials.$view"; } if (! $this->view->exists($path)) { throw new UnknownPartialFileException("Partial view [$view] not found."); } } $partial = $this->view->make($path, $args)->render(); $this->regions[$view] = $partial; return $this->regions[$view]; } /** * Watch and set up a partial from anywhere. * * This method will first try to load the partial from current theme. If partial * is not found in theme then it loads it from app (i.e. app/views/partials) * * @param string $view * @param array $args * @throws UnknownPartialFileException * @return mixed */ public function watchPartial($view, $args = array()) { try { return $this->partial($view, $args); } catch (UnknownPartialFileException $e) { return $this->loadPartial($view, 'partials', $args); } } /** * Widget instance. * * @param string $className * @param array $attributes * @throws UnknownWidgetClassException * @return Facuz\Theme\Widget */ public function widget($className, $attributes = array()) { static $widgets = array(); // If the class name is not lead with upper case add prefix "Widget". if (! preg_match('|^[A-Z]|', $className)) { $className = ucfirst($className); } $widgetNamespace = $this->getConfig('namespaces.widget'); $className = $widgetNamespace.'\\'.$className; if (! $instance = Arr::get($widgets, $className)) { $reflector = new ReflectionClass($className); if (! $reflector->isInstantiable()) { throw new UnknownWidgetClassException("Widget target [$className] is not instantiable."); } $instance = $reflector->newInstance($this, $this->config, $this->view); array_set($widgets, $className, $instance); } $instance->setAttributes($attributes); $instance->beginWidget(); $instance->endWidget(); return $instance; } /** * Hook a partial before rendering. * * @param mixed $view * @param closure $callback * @return void */ public function partialComposer($view, $callback, $layout = null) { if (! is_array($view)) { $view = array($view); } // Partial path with namespace. $path = $this->getThemeNamespace('partials'); // This code support partialWithLayout. if (! is_null($layout)) { $path = $path.'.'.$layout; } $view = array_map(function($v) use ($path) { return $path.'.'.$v; }, $view); $this->view->composer($view, $callback); } /** * Get compiler. * * @param string $compiler * @return object */ public function getCompiler($compiler) { if (isset($this->compilers[$compiler])) { return $this->compilers[$compiler]; } } /** * Parses and compiles strings by using blade template system. * * @param string $str * @param array $data * @param boolean $phpCompile * @throws \Exception * @return string */ public function blader($str, $data = array(), $phpCompile = true) { if ($phpCompile == false) { $patterns = array('|<\?|', '|<\?php|', '|<\%|', '|\?>|', '|\%>|'); $replacements = array('&lt;?', '&lt;php', '&lt;%', '?&gt;', '%&gt;'); $str = preg_replace($patterns, $replacements, $str); } // Get blade compiler. $parsed = $this->getCompiler('blade')->compileString($str); ob_start() and extract($data, EXTR_SKIP); try { eval('?>'.$parsed); } catch (\Exception $e) { ob_end_clean(); throw $e; } $str = ob_get_contents(); ob_end_clean(); return $str; } /** * Compile blade without PHP. * * @param string $str * @param array $data * @return string */ public function bladerWithOutServerScript($str, $data = array()) { return $this->blader($str, $data, false); } /** * Check region exists. * * @param string $region * @return boolean */ public function has($region) { return (boolean) isset($this->regions[$region]); } /** * Render a region. * * @param string $region * @param mixed $default * @return string */ public function get($region, $default = null) { if ($this->has($region)) { return $this->regions[$region]; } return $default ? $default : ''; } /** * Place content in sub-view. * * @return string */ public function content() { return $this->regions['content']; } /** * Return asset instance. * * @return \Facuz\Theme\Asset */ public function asset() { return $this->asset; } /** * Return breadcrumb instance. * * @return \Facuz\Theme\Breadcrumb */ public function breadcrumb() { return $this->breadcrumb; } /** * Set up a content to template. * * @param string $view * @param array $args * @param string $type * @return Theme */ public function of($view, $args = array(), $type = null) { // Layout. $layout = ucfirst($this->layout); // Fire event global assets. $this->fire('asset', $this->asset); // Fire event before render theme. $this->fire('beforeRenderTheme', $this); // Fire event before render layout. $this->fire('beforeRenderLayout.'.$this->layout, $this); // Keeping arguments. $this->arguments = $args; // Compile string blade, or from file path. switch ($type) { case 'blade' : $content = $this->bladerWithOutServerScript($view, $args); break; default : $content = $this->view->make($view, $args)->render(); break; } // View path of content. $this->content = $view; // Set up a content regional. $this->regions['content'] = $content; return $this; } /** * The same as "of", but having prefix layout. * * @param string $view * @param array $args * @param string $type * @return Theme */ public function ofWithLayout($view, $args = array(), $type = null) { $view = $this->getLayoutName().'.'.$view; return $this->of($view, $args, $type); } /** * Container view. * * Using a container module view inside a theme, this is * useful when you separate a view inside a theme. * * @param string $view * @param array $args * @param string $type * @return Theme */ public function scope($view, $args = array(), $type = null) { // Add namespace to find in a theme path. $path = $this->getThemeNamespace('views.'.$view); return $this->of($path, $args, $type); } /** * The same as "scope", but having prefix layout. * * @param string $view * @param array $args * @param string $type * @return Theme */ public function scopeWithLayout($view, $args = array(), $type = null) { $view = $this->getLayoutName().'.'.$view; return $this->scope($view, $args, $type); } /** * Load subview from direct path. * * @param string $view * @param array $args * @return Theme */ public function load($view, $args = array()) { $view = ltrim($view, '/'); $segments = explode('/', str_replace('.', '/', $view)); // Pop file from segments. $view = array_pop($segments); // Custom directory path. $pathOfView = app('path.base').'/'.implode('/', $segments); // Add temporary path with a hint type. $this->view->addNamespace('custom', $pathOfView); return $this->of('custom::'.$view, $args); } /** * Watch view file in anywhere. * * Finding from scope first, then try to find from application view. * * @param string $view * @param array $args * @param string $type * @return Theme */ public function watch($view, $args = array(), $type = null) { try { return $this->scope($view, $args, $type); } catch (\InvalidArgumentException $e) { $fallback = config('theme.view_fallback', ''); if (!empty($fallback)) { $view = "$fallback.$view"; } return $this->of($view, $args, $type); } } /** * The same as "watch", but having prefix layout. * * Finding from scope first, then try to find from application view. * * @param string $view * @param array $args * @param string $type * @return Theme */ public function watchWithLayout($view, $args = array(), $type = null) { try { return $this->scopeWithLayout($view, $args, $type); } catch (\InvalidArgumentException $e) { return $this->ofWithLayout($view, $args, $type); } } /** * Get all arguments assigned to content. * * @return mixed */ public function getContentArguments() { return $this->arguments; } /** * Get a argument assigned to content. * * @param string $key * @param null $default * @return mixed */ public function getContentArgument($key, $default = null) { return Arr::get($this->arguments, $key, $default); } /** * Checking content argument existing. * * @param string $key * @return boolean */ public function hasContentArgument($key) { return (bool) isset($this->arguments[$key]); } /** * Find view location. * * @param boolean $realpath * @return string */ public function location($realpath = false) { try { if ($this->view->exists($this->content)) { return ($realpath) ? $this->view->getFinder()->find($this->content) : $this->content; } } catch (\InvalidArgumentException $e) { return null; } } /** * It's similar to location, but will look up from both * application's view and theme's view. * * ex. Theme::which('general.welcome'); * * @param string $view * @param boolean $realpath * @return string */ public function which($view, $realpath = false) { return $this->watch($view)->location($realpath); } /** * Compile from string. * * @param string $str * @param array $args * @param string $type * @return Theme */ public function string($str, $args = array(), $type = 'blade') { $shared = $this->view->getShared(); $data['errors'] = $shared['errors']; $args = array_merge($data, $args); return $this->of($str, $args, $type); } /** * Set cookie to response. * * @param Cookie $cookie * @return Theme */ public function withCookie(Cookie $cookie) { $this->cookie = $cookie; return $this; } /** * Return a template with content. * * @param integer $statusCode * @throws UnknownLayoutFileException * @return Response */ public function render($statusCode = 200) { // Fire the event before render. $this->fire('after', $this); // Flush asset that need to serve. $this->asset->flush(); $path = $this->getThemeNamespace('layouts.'.$this->layout); if (!$this->view->exists($path)) { $fallback = config('theme.view_fallback', ''); if (!empty($fallback)) { $path = "$fallback.layouts." . $this->layout; } if (!$this->view->exists($path)) { $path = "$fallback.layouts.layout"; if (!$this->view->exists($path)) { throw new UnknownLayoutFileException("Layout [$this->layout] not found."); } } } $content = $this->view->make($path)->render(); // Append status code to view. $content = new Response($content, $statusCode); // Having cookie set. if ($this->cookie) { $content->withCookie($this->cookie); } return $content; } /** * Magic method for set, prepend, append, has, get. * * @param string $method * @param array $parameters * @return mixed */ public function __call($method, $parameters = array()) { $callable = preg_split('|[A-Z]|', $method); if (in_array($callable[0], array('set', 'prepend', 'append', 'has', 'get'))) { $value = lcfirst(preg_replace('|^'.$callable[0].'|', '', $method)); array_unshift($parameters, $value); return call_user_func_array(array($this, $callable[0]), $parameters); } trigger_error('Call to undefined method '.__CLASS__.'::'.$method.'()', E_USER_ERROR); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Exceptions.php
src/Exceptions.php
<?php namespace Facuz\Theme; class UnknownThemeException extends \UnexpectedValueException {} class UnknownViewFileException extends \UnexpectedValueException {} class UnknownLayoutFileException extends \UnexpectedValueException {} class UnknownWidgetFileException extends \UnexpectedValueException {} class UnknownWidgetClassException extends \UnexpectedValueException {} class UnknownPartialFileException extends \UnexpectedValueException {} class UnknownFileException extends \UnexpectedValueException {}
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Breadcrumb.php
src/Breadcrumb.php
<?php namespace Facuz\Theme; use Illuminate\Support\Facades\URL; use Illuminate\Filesystem\Filesystem; use Illuminate\View\Compilers\BladeCompiler; class Breadcrumb { /** * Template * * @var string */ public $template = ''; /** * Crumbs * * @var array */ public $crumbs = array(); /** * Filesystem. * * @var Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new breadcrumb instance. * * @param \Illuminate\Filesystem\Filesystem $files * * @return \Facuz\Theme\Breadcrumb */ public function __construct(Filesystem $files) { $this->files = $files; // Template for breadcrumb. $this->template = ' <ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"> @foreach ($crumbs as $i => $crumb) @if ($i != (count($crumbs) - 1)) <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <meta itemprop="position" content="{{ $i + 1}}" /> <a href="{{ $crumb["url"] }}" itemprop="item" title="{{ $crumb["label"] }}"> {!! $crumb["label"] !!} <meta itemprop="name" content="{{ $crumb["label"] }}" /> </a> <span class="divider">/</span> </li> @else <li class="active">{!! $crumb["label"] !!}</li> @endif @endforeach </ul> '; } /** * Set template. * * @param string */ public function setTemplate($template) { $this->template = $template; } /** * Add breadcrumb to array. * * @param mixed $label * @param string $url * @return Breadcrumb */ public function add($label, $url='') { if (is_array($label)) { if (count($label) > 0) foreach ($label as $crumb) { $defaults = [ 'label' => '', 'url' => '' ]; $crumb = array_merge($defaults, $crumb); $this->add($crumb['label'], $crumb['url']); } } else { $label = trim(strip_tags($label, '<i><b><strong>')); if (! preg_match('|^http(s)?|', $url)) { $url = URL::to($url); } $this->crumbs[] = array('label' => $label, 'url' => $url); } return $this; } /** * Get crumbs. * * @return array */ public function getCrumbs() { return $this->crumbs; } /** * Compile blade template to HTML. * * @param string $template * @param array $data * * @throws \Exception * @return string */ public function compile($template, $data = array()) { $compiler = new BladeCompiler($this->files, 'theme'); // Get blade compiler. $parsed = $compiler->compileString($template); ob_start() and extract($data, EXTR_SKIP); try { eval('?>'.$parsed); } catch (\Exception $e) { ob_end_clean(); throw $e; } $template = ob_get_contents(); ob_end_clean(); return $template; } /** * Render breadcrumbs. * * @return string */ public function render() { $crumbs = $this->getCrumbs(); return $this->compile($this->template, compact('crumbs')); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/helpers.php
src/helpers.php
<?php if (!function_exists('theme')){ /** * Get the theme instance. * * @param string $themeName * @param string $layoutName * @return \Facuz\Theme\Theme */ function theme($themeName = null, $layoutName = null){ $theme = app('theme'); if ($themeName){ $theme->theme($themeName); } if ($layoutName){ $theme->layout($layoutName); } return $theme; } } if (!function_exists('protectEmail')){ /** * Protect the Email address against bots or spiders that * index or harvest addresses for sending you spam. * * @param string $email * @return string */ function protectEmail($email) { $p = str_split(trim($email)); $new_mail = ''; foreach ($p as $val) { $new_mail .= '&#'.ord($val).';'; } return $new_mail; } } if (!function_exists('meta_init')){ /** * Returns common metadata * * @return string */ function meta_init() { return '<meta charset="utf-8">'. '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">'. '<meta name="viewport" content="width=device-width, initial-scale=1">'; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/ThemeServiceProvider.php
src/ThemeServiceProvider.php
<?php namespace Facuz\Theme; use Illuminate\Support\Facades\Blade; use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; class ThemeServiceProvider extends ServiceProvider { /** * Indicates if loading of the provider is deferred. * * @var bool */ protected $defer = false; /** * Bootstrap the application events. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { $configPath = __DIR__.'/../config/theme.php'; // Publish config. $this->publishes([$configPath => config_path('theme.php')], 'config'); $router->aliasMiddleware('theme', Middleware\ThemeLoader::class); // Register blade directives: $this->addToBlade(['dd', 'dd(%s);']); $this->addToBlade(['dv', 'dd(get_defined_vars()[%s]);', 'dd(get_defined_vars()["__data"]);']); $this->addToBlade(['d', 'dump(%s);']); $this->addToBlade(['get', 'Theme::get(%s);']); $this->addToBlade(['getIfHas', 'Theme::has(%1$s) ? Theme::get(%1$s) : ""']); $this->addToBlade(['partial', 'Theme::partial(%s, get_defined_vars()["__data"]);']); $this->addToBlade(['sections', 'Theme::partial("sections.".%s, get_defined_vars()["__data"]);']); $this->addToBlade(['content', null, 'Theme::content();']); $this->addToBlade(['asset', 'Theme::asset()->absUrl(%s);']); $this->addToBlade(['protect', 'protectEmail(%s);']); $this->addToBlade(['styles', 'Theme::asset()->container(%s)->styles();', 'Theme::asset()->styles();']); $this->addToBlade(['scripts', 'Theme::asset()->container(%s)->scripts();', 'Theme::asset()->scripts();']); $this->addToBlade(['widget', 'Theme::widget(%s)->render();']); } /** * Register service provider. * * @return void */ public function register() { $configPath = __DIR__.'/../config/theme.php'; // Merge config to allow user overwrite. $this->mergeConfigFrom($configPath, 'theme'); $app = $this->app; // Register providers: $this->registerAsset(); $this->registerTheme(); $this->registerWidget(); $this->registerBreadcrumb(); $this->registerManifest(); // Register commands: $this->registerThemeGenerator(); $this->registerWidgetGenerator(); $this->registerThemeList(); $this->registerThemeDuplicate(); $this->registerThemeDestroy(); // Assign commands: $this->commands( 'theme.create', 'theme.widget', 'theme.list', 'theme.duplicate', 'theme.destroy' ); } /** * Set a blade directive * * @return void */ protected function addToBlade($array){ Blade::directive($array[0], function ($data) use ($array) { if(!$data) return '<?php echo '.$array[2].' ?>'; return sprintf('<?php echo '.$array[1].' ?>', null !== $data ? $data : "get_defined_vars()['__data']" ); }); } /** * Register asset provider. * * @return void */ public function registerAsset() { $this->app->singleton('asset', function($app) { return new Asset(); }); } /** * Register theme provider. * * @return void */ public function registerTheme() { $this->app->singleton('theme', function($app) { return new Theme($app['config'], $app['events'], $app['view'], $app['asset'], $app['files'], $app['breadcrumb'], $app['manifest']); }); $this->app->alias('theme', 'Facuz\Theme\Contracts\Theme'); } /** * Register widget provider. * * @return void */ public function registerWidget() { $this->app->singleton('widget', function($app) { return new Widget($app['view']); }); } /** * Register breadcrumb provider. * * @return void */ public function registerBreadcrumb() { $this->app->singleton('breadcrumb', function($app) { return new Breadcrumb($app['files']); }); } /** * Register manifest provider. * * @return void */ public function registerManifest() { $this->app->singleton('manifest', function($app) { return new Manifest($app['files']); }); } /** * Register generator of theme. * * @return void */ public function registerThemeGenerator() { $this->app->singleton('theme.create', function($app) { return new Commands\ThemeGeneratorCommand($app['config'], $app['files']); }); } /** * Register duplicate of theme. * * @return void */ public function registerThemeDuplicate() { $this->app->singleton('theme.duplicate', function($app) { return new Commands\ThemeDuplicateCommand($app['config'], $app['files']); }); } /** * Register generator of widget. * * @return void */ public function registerWidgetGenerator() { $this->app->singleton('theme.widget', function($app) { return new Commands\WidgetGeneratorCommand($app['config'], $app['files']); }); } /** * Register theme destroy. * * @return void */ public function registerThemeDestroy() { $this->app->singleton('theme.destroy', function($app) { return new Commands\ThemeDestroyCommand($app['config'], $app['files']); }); } /** * Register list themes. * * @return void */ public function registerThemeList() { $this->app->singleton('theme.list', function($app) { return new Commands\ThemeListCommand($app['config'], $app['files']); }); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return array('asset', 'theme', 'widget', 'breadcrumb'); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Widget.php
src/Widget.php
<?php namespace Facuz\Theme; use Closure; use Illuminate\View\Factory; use Illuminate\Config\Repository; abstract class Widget { /** * Theme instanced. * * @var Theme; */ protected $theme; /** * Repository config. * * @var \Illuminate\Config\Repository */ protected $config; /** * Environment view. * * @var \Illuminate\View\Factory */ protected $view; /** * Widget file template. * * @var string */ public $template; /** * Watching widget template. * * @var boolean */ public $watch; /** * Default attributes. * * @var array */ public $attributes = array(); /** * Attributes including data. * * @var array */ public $data = array(); /** * Turn on/off widget. * * @var boolean */ public $enable = true; /** * Default fallback blade path. * * @var string */ public $path = 'widgets'; /** * Create a new theme instance. * * @param Theme $theme * @param \Illuminate\Config\Repository $config * @param \Illuminate\View\Factory $view * @return \Facuz\Theme\Widget */ public function __construct(Theme $theme, Repository $config, Factory $view) { // Theme name. $this->theme = $theme; // Laravel config $this->config = $config; $this->view = $view; } /** * Abstract class init for a widget factory. * * @return void */ //abstract public function init(); /** * Abstract class run for a widget factory. * * @return void */ abstract public function run(); /** * Set attributes to object var. * * @param arary $attributes * @return void */ public function setAttributes($attributes) { $this->attributes = array_merge($this->attributes, $attributes); } /** * Set attribute. * * @param string $key * @param mixed $value */ public function setAttribute($key, $value) { $this->attributes[$key] = $value; } /** * Get attributes. * * @return array */ public function getAttributes() { return $this->attributes; } /** * Get attribute with a key. * * @param string $key * @param string $default * @return mixed */ public function getAttribute($key, $default = null) { return array_get($this->attributes, $key, $default); } /** * Disble widget. * * @return void */ protected function disable() { $this->enable = false; } /** * Start widget factory. * * @return void */ public function beginWidget() { // Init widget when enable is true. if ($this->enable == true) { $this->init($this->theme); } } /** * End widget factory. * * @return void */ public function endWidget() { $data = (array) $this->run(); $this->data = array_merge($this->attributes, $data); } /** * Watch widget tpl in theme, also app/views/widgets/ too. * * @param boolean $bool * @return Widget */ public function watch($bool = true) { $this->watch = $bool; return $this; } /** * Render widget to HTML. * * @throws UnknownWidgetFileException * @return string */ public function render() { if($this->enable == false) return ''; $path = $this->theme->getThemeNamespace('widgets.'.$this->template); // If not found in theme widgets directory, try to watch in views/widgets again. if($this->watch === true and ! $this->view->exists($path)){ $path = $this->path.'.'.$this->template; } // Error file not exists. if(!$this->view->exists($path)){ throw new UnknownWidgetFileException("Widget view [$this->template] not found."); } $widget = $this->view->make($path, $this->data)->render(); return $widget; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Asset.php
src/Asset.php
<?php namespace Facuz\Theme; use Closure; use Illuminate\Support\Facades\URL; class Asset { /** * Path to assets. * * @var string */ public static $path; /** * All of the instantiated asset containers. * * @var array */ public static $containers = array(); /** * Asset buffering. * * @var array */ protected $stacks = array( 'cooks' => array(), 'serves' => array() ); /** * Asset construct. */ public function __construct() { // } /** * Add a path to theme. * * @param string $path */ public function addPath($path) { static::$path = rtrim($path, '/').'/'; } /** * Get an asset container instance. * * <code> * // Get the default asset container * $container = Asset::container(); * * // Get a named asset container * $container = Asset::container('footer'); * </code> * * @param string $container * @return AssetContainer */ public static function container($container = 'default') { if ( ! isset(static::$containers[$container])) { static::$containers[$container] = new AssetContainer($container); } return static::$containers[$container]; } /** * Cooking your assets. * * @param string $name * @param Closure $callbacks * @return void */ public function cook($name, Closure $callbacks) { $this->stacks['cooks'][$name] = $callbacks; } /** * Serve asset preparing from cook. * * @param string $name * @return Asset */ public function serve($name) { $this->stacks['serves'][$name] = true; return $this; } /** * Flush all cooks. * * @return void */ public function flush() { foreach ($this->stacks['serves'] as $key => $val) { if (array_key_exists($key, $this->stacks['cooks'])) { $callback = $this->stacks['cooks'][$key]; if ($callback instanceof Closure) { $callback($this); } } } } /** * Magic Method for calling methods on the default container. * * <code> * // Call the "styles" method on the default container * echo Asset::styles(); * * // Call the "add" method on the default container * Asset::add('jquery', 'js/jquery.js'); * </code> */ public function __call($method, $parameters) { return call_user_func_array(array(static::container(), $method), $parameters); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Manifest.php
src/Manifest.php
<?php namespace Facuz\Theme; use Illuminate\Filesystem\Filesystem; class Manifest { /** * Path of all themes. * * @var array */ protected $themePath; /** * Filesystem. * * @var \Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new theme instance. * * @param \Illuminate\Filesystem\Filesystem $files * @return \Facuz\Theme\Manifest */ public function __construct(Filesystem $files) { $this->files = $files; } /** * Sets the specified themes path. * * @param string $themePath * @return void */ public function setThemePath($themePath){ $this->themePath = $themePath; } /** * Get path of theme JSON file. * * @return string */ public function getJsonPath() { return $this->themePath.'/theme.json'; } /** * Get theme JSON content as an array. * * @return array|mixed */ public function getJsonContents() { $default = []; $path = $this->getJsonPath(); if ($this->files->exists($path)) { $contents = $this->files->get($path); return json_decode($contents, true); } else { throw new UnknownFileException("The theme must have a valid theme.json manifest file."); } } /** * Set theme manifest JSON content property value. * * @param array $content * @return integer */ protected function setJsonContents(array $content) { $content = json_encode($content, JSON_PRETTY_PRINT); return $this->files->put($this->getJsonPath(), $content); } /** * Get a theme manifest key value. * * @param string $key * @param null|string $default * @return mixed */ public function getProperty($key, $default = null) { return array_get($this->getJsonContents(), $key, $default); } /** * Set a theme manifest key value. * * @param string $key * @param mixed $value * @return bool */ public function setProperty($key, $value) { $content = $this->getJsonContents(); if (count($content)) { if (isset($content[$key])) { unset($content[$key]); } $content[$key] = $value; $this->setJsonContents($content); return true; } return false; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/AssetContainer.php
src/AssetContainer.php
<?php namespace Facuz\Theme; use Closure; use Illuminate\Support\Str; use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\HTML; use Illuminate\Support\Facades\Request; class AssetContainer { /** * Use a theme path. * * @var boolean */ public $usePath = false; /** * Path to theme. * * @var string */ public $path; /** * The asset container name. * * @var string */ public $name; /** * Create a new asset container instance. * * @param string $name */ public function __construct($name) { $this->name = $name; } /** * Get path from asset. * * @return string */ public function getCurrentPath() { return Asset::$path; } /** * Generate a URL to an application asset. * * @param string $path * @param bool $secure * @return string */ protected function configAssetUrl($path, $secure = null) { static $assetUrl; // Remove this. $i = 'index.php'; if (URL::isValidUrl($path)) return $path; // Finding asset url config. if (is_null($assetUrl)) { $assetUrl = \Config::get('theme.assetUrl', ''); } // Using asset url, if available. if ($assetUrl) { $base = rtrim($assetUrl, '/'); // Asset URL without index. $basePath = Str::contains($base, $i) ? str_replace('/'.$i, '', $base) : $base; } else { if (is_null($secure)) { $scheme = Request::getScheme().'://'; } else { $scheme = $secure ? 'https://' : 'http://'; } // Get root URL. $root = Request::root(); $start = starts_with($root, 'http://') ? 'http://' : 'https://'; $root = preg_replace('~'.$start.'~', $scheme, $root, 1); // Asset URL without index. $basePath = Str::contains($root, $i) ? str_replace('/'.$i, '', $root) : $root; } return $basePath.'/'.$path; } /** * Root asset path. * * @param string $uri * @param boolean $secure * @return string */ public function originUrl($uri, $secure = null) { return $this->configAssetUrl($uri, $secure); } /** * Return asset path with current theme path. * * @param string $uri * @param boolean $secure * @return string */ public function url($uri, $secure = null) { // If path is full, so we just return. if (preg_match('#^http|//:#', $uri)) { return $uri; } $path = $this->getCurrentPath().$uri; if(substr($path, 0, 6)=='public') $path = substr($path, 7); return $this->configAssetUrl($path, $secure); } /** * Return asset absolute path with current theme path. * * @param string $uri * @param boolean $secure * @return string */ public function absUrl($uri, $secure = null) { $source = $this->url($uri, $secure); if(substr($source, 0, 7)=='/public') $source = substr($source, 7); return url($source); } /** * Add an asset to the container. * * The extension of the asset source will be used to determine the type of * asset being registered (CSS or JavaScript). When using a non-standard * extension, the style/script methods may be used to register assets. * * <code> * // Add an asset to the container * Asset::container()->add('jquery', 'js/jquery.js'); * * // Add an asset that has dependencies on other assets * Asset::add('jquery', 'js/jquery.js', 'jquery-ui'); * * // Add an asset that should have attributes applied to its tags * Asset::add('jquery', 'js/jquery.js', null, array('defer')); * </code> * * @param string $name * @param string $source * @param array $dependencies * @param array $attributes * @return AssetContainer */ protected function added($name, $source, $dependencies = array(), $attributes = array()) { if (is_array($source)) { foreach ($source as $path) { $name = $name.'-'.md5($path); $this->added($name, $path, $dependencies, $attributes); } } else { $type = (pathinfo(parse_url($source, PHP_URL_PATH), PATHINFO_EXTENSION) == 'css') ? 'style' : 'script'; // Remove unnecessary slashes from internal path. if ( ! preg_match('|^//|', $source)) { $source = ltrim($source, '/'); } return $this->$type($name, $source, $dependencies, $attributes); } } /** * Alias add an asset to container. * * @param string $name * @param string $source * @param array $dependencies * @param array $attributes * @return AssetContainer */ public function add($name, $source = null, $dependencies = array(), $attributes = array()) { if(!is_array($name)) { if(!isset($source)) throw new \ErrorException("Missing argument 2 for Facuz\Theme\AssetContainer::add()", 1); return $this->added($name, $source, $dependencies, $attributes); } foreach ($name as $array) { if(count($array) < 2) throw new \ErrorException("Missing value 2 of the array for Facuz\Theme\AssetContainer::add()", 1); $container = $array[0]; $source = $array[1]; $dependencies = isset($array[2]) ? $array[2] : []; $attributes = isset($array[3]) ? $array[3] : []; $this->add($container, $source, $dependencies, $attributes); } $this->usePath(false); } /** * Write a content to the container. * * @param string $name * @param string string * @param string $source * @param array $dependencies * @return AssetContainer */ protected function write($name, $type, $source, $dependencies = array()) { $types = array( 'script' => 'script', 'style' => 'style', 'js' => 'script', 'css' => 'style' ); if (array_key_exists($type, $types)) { $type = $types[$type]; $this->register($type, $name, $source, $dependencies, array()); } return $this; } /** * Write a script to the container. * * @param string $name * @param string string * @param string $source * @param array $dependencies * @return AssetContainer */ public function writeScript($name, $source, $dependencies = array()) { $source = '<script>'.$source.'</script>'; return $this->write($name, 'script', $source, $dependencies); } /** * Write a style to the container. * * @param string $name * @param string string * @param string $source * @param array $dependencies * @return AssetContainer */ public function writeStyle($name, $source, $dependencies = array()) { $source = '<style>'.$source.'</style>'; return $this->write($name, 'style', $source, $dependencies); } /** * Write a content without tag wrapper. * * @param string $name * @param string string * @param string $source * @param array $dependencies * @return AssetContainer */ public function writeContent($name, $source, $dependencies = array()) { $source = $source; return $this->write($name, 'script', $source, $dependencies); } /** * Add a CSS file to the registered assets. * * @param string $name * @param string $source * @param array $dependencies * @param array $attributes * @return AssetContainer */ public function style($name, $source, $dependencies = array(), $attributes = array()) { if ( ! array_key_exists('media', $attributes)) { $attributes['media'] = 'all'; } // Prepend path to theme. if ($this->isUsePath()) { $source = $this->evaluatePath($this->getCurrentPath().$source); } $this->register('style', $name, $source, $dependencies, $attributes); return $this; } /** * Add a JavaScript file to the registered assets. * * @param string $name * @param string $source * @param array $dependencies * @param array $attributes * @return AssetContainer */ public function script($name, $source, $dependencies = array(), $attributes = array()) { // Prepaend path to theme. if ($this->isUsePath()) { $source = $this->evaluatePath($this->getCurrentPath().$source); } $this->register('script', $name, $source, $dependencies, $attributes); return $this; } /** * Evaluate path to current theme or force use theme. * * @param string $source * @return string */ protected function evaluatePath($source) { static $theme; // Make theme to use few features. if ( ! $theme) { $theme = \App::make('theme'); } // Switch path to another theme. if ( ! is_bool($this->usePath) and $theme->exists($this->usePath)) { $currentTheme = $theme->getThemeName(); $source = str_replace($currentTheme, $this->usePath, $source); } return $source; } /** * Force use a theme path. * * @param boolean $use * @return AssetContainer */ public function usePath($use = true) { $this->usePath = $use; return $this; } /** * Alias to usePath() * * @param boolean $use * @return AssetContainer */ public function themePath($use = true) { return $this->usePath($use); } /** * Check using theme path. * * @return boolean */ public function isUsePath() { return (boolean) $this->usePath; } /** * Returns the full-path for an asset. * * @param string $source * @return string */ public function path($source) { return $source; } /** * Add an asset to the array of registered assets. * * @param string $type * @param string $name * @param string $source * @param array $dependencies * @param array $attributes * @return void */ protected function register($type, $name, $source, $dependencies, $attributes) { $dependencies = (array) $dependencies; $attributes = (array) $attributes; $this->assets[$type][$name] = compact('source', 'dependencies', 'attributes'); } /** * Get the links to all of the registered CSS assets. * * @return string */ public function styles() { return $this->group('style'); } /** * Get the links to all of the registered JavaScript assets. * * @return string */ public function scripts() { return $this->group('script'); } /** * Get all of the registered assets for a given type / group. * * @param string $group * @return string */ protected function group($group) { if ( ! isset($this->assets[$group]) or count($this->assets[$group]) == 0) return ''; $assets = ''; foreach ($this->arrange($this->assets[$group]) as $name => $data) { $assets .= $this->asset($group, $name); } return $assets; } /** * Get the HTML link to a registered asset. * * @param string $group * @param string $name * @return string */ protected function asset($group, $name) { if ( ! isset($this->assets[$group][$name])) return ''; $asset = $this->assets[$group][$name]; // If the bundle source is not a complete URL, we will go ahead and prepend // the bundle's asset path to the source provided with the asset. This will // ensure that we attach the correct path to the asset. if (filter_var($asset['source'], FILTER_VALIDATE_URL) === false) { $asset['source'] = $this->path($asset['source']); } // If source is not a path to asset, render without wrap a HTML. if (strpos($asset['source'], '<') !== false) { return $asset['source']; } // This line fixing config path. $asset['source'] = $this->configAssetUrl($asset['source']); //return HTML::$group($asset['source'], $asset['attributes']); return $this->html($group, $asset['source'], $asset['attributes']); } /** * Render asset as HTML. * * @param string $group * @param mixed $source * @param array $attributes * @return string */ public function html($group, $source, $attributes) { $result = substr($source, 0, 7); if($result=='/public') $source = substr($source, 7); $source = url($source); switch ($group) { case 'script' : $attributes['src'] = $source; return '<script'.$this->attributes($attributes).'></script>'.PHP_EOL; case 'style' : $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'); $attributes = $attributes + $defaults; $attributes['href'] = $source; return '<link'.$this->attributes($attributes).'>'.PHP_EOL; } } /** * Build an HTML attribute string from an array. * * @param array $attributes * @return string */ public function attributes($attributes) { $html = array(); // For numeric keys we will assume that the key and the value are the same // as this will convert HTML attributes such as "required" to a correct // form like required="required" instead of using incorrect numerics. foreach ((array) $attributes as $key => $value) { $element = $this->attributeElement($key, $value); if ( ! is_null($element)) $html[] = $element; } return count($html) > 0 ? ' '.implode(' ', $html) : ''; } /** * Build a single attribute element. * * @param string $key * @param string $value * @return string */ protected function attributeElement($key, $value) { if (is_numeric($key)) $key = $value; if ( ! is_null($value)) return $key.'="'.e($value).'"'; } /** * Sort and retrieve assets based on their dependencies * * @param array $assets * @return array */ protected function arrange($assets) { list($original, $sorted) = array($assets, array()); while (count($assets) > 0) { foreach ($assets as $asset => $value) { $this->evaluateAsset($asset, $value, $original, $sorted, $assets); } } return $sorted; } /** * Evaluate an asset and its dependencies. * * @param string $asset * @param string $value * @param array $original * @param array $sorted * @param array $assets * @return void */ protected function evaluateAsset($asset, $value, $original, &$sorted, &$assets) { // If the asset has no more dependencies, we can add it to the sorted list // and remove it from the array of assets. Otherwise, we will not verify // the asset's dependencies and determine if they've been sorted. if (count($assets[$asset]['dependencies']) == 0) { $sorted[$asset] = $value; unset($assets[$asset]); } else { foreach ($assets[$asset]['dependencies'] as $key => $dependency) { if ( ! $this->dependecyIsValid($asset, $dependency, $original, $assets)) { unset($assets[$asset]['dependencies'][$key]); continue; } // If the dependency has not yet been added to the sorted list, we can not // remove it from this asset's array of dependencies. We'll try again on // the next trip through the loop. if ( ! isset($sorted[$dependency])) continue; unset($assets[$asset]['dependencies'][$key]); } } } /** * Verify that an asset's dependency is valid. * A dependency is considered valid if it exists, is not a circular reference, and is * not a reference to the owning asset itself. If the dependency doesn't exist, no * error or warning will be given. For the other cases, an exception is thrown. * * @param string $asset * @param string $dependency * @param array $original * @param array $assets * * @throws \Exception * @return bool */ protected function dependecyIsValid($asset, $dependency, $original, $assets) { if ( ! isset($original[$dependency])) { return false; } elseif ($dependency === $asset) { throw new \Exception("Asset [$asset] is dependent on itself."); } elseif (isset($assets[$dependency]) and in_array($asset, $assets[$dependency]['dependencies'])) { throw new \Exception("Assets [$asset] and [$dependency] have a circular dependency."); } return true; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Contracts/Theme.php
src/Contracts/Theme.php
<?php namespace Facuz\Theme\Contracts; interface Theme { }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Facades/Theme.php
src/Facades/Theme.php
<?php namespace Facuz\Theme\Facades; use Illuminate\Support\Facades\Facade; class Theme extends Facade { /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'theme'; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Facades/Breadcrumb.php
src/Facades/Breadcrumb.php
<?php namespace Facuz\Theme\Facades; use Illuminate\Support\Facades\Facade; class Breadcrumb extends Facade { /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'breadcrumb'; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Facades/Asset.php
src/Facades/Asset.php
<?php namespace Facuz\Theme\Facades; use Illuminate\Support\Facades\Facade; class Asset extends Facade { /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'asset'; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Middleware/ThemeLoader.php
src/Middleware/ThemeLoader.php
<?php namespace Facuz\Theme\Middleware; use Closure, Theme; class ThemeLoader { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param String $theme * @param String $layout * @return mixed */ public function handle($request, Closure $next, $theme = null, $layout = null) { if(isset($theme)) Theme::uses($theme); if(isset($layout)) Theme::layout($layout); return $next($request); /* $response = $next($request); $originalContent = $response->getOriginalContent(); if(!is_string($originalContent)) { $view_name = $originalContent->getName(); $data = $originalContent->getData(); } else { $view_name = $response->exception->getTrace()[0]['args'][0]; } return $theme->scope($view_name, $data)->render(); */ } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/layout.blade.php
src/templates/layout.blade.php
<!DOCTYPE html> <html lang="en"> <head> {!! meta_init() !!} <meta name="keywords" content="@get('keywords')"> <meta name="description" content="@get('description')"> <meta name="author" content="@get('author')"> <title>@get('title')</title> @styles() </head> <body> @partial('header') @content() @partial('footer') @scripts() </body> </html>
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/widgetClass.php
src/templates/widgetClass.php
<?php namespace {widgetNamespace}; use Facuz\Theme\Theme; use Facuz\Theme\Widget; class {widgetClass} extends Widget { /** * Widget template. * * @var string */ public $template = '{widgetTemplate}'; /** * Watching widget tpl on everywhere. * * @var boolean */ public $watch = {watch}; /** * Arrtibutes pass from a widget. * * @var array */ public $attributes = array( //'userId' => 9999, 'label' => 'Default widget label', ); /** * Turn on/off widget. * * @var boolean */ public $enable = true; /** * Code to start this widget. * * @return void */ public function init(Theme $theme) { // Initialize widget. //$theme->asset()->usePath()->add('widget-name', 'js/widget-execute.js', array('jquery', 'jqueryui')); //$this->setAttribute('user', User::find($this->getAttribute('userId'))); } /** * Logic given to a widget and pass to widget's view. * * @return array */ public function run() { //$label = $this->getAttribute('label'); //$this->setAttribute('label', 'changed'); $attrs = $this->getAttributes(); return $attrs; } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/index.blade.php
src/templates/index.blade.php
@sections('main')
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/header.blade.php
src/templates/header.blade.php
<header>Header</header>
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/config.php
src/templates/config.php
<?php return array( /* |-------------------------------------------------------------------------- | Inherit from another theme |-------------------------------------------------------------------------- | | Set up inherit from another if the file is not exists, this | is work with "layouts", "partials", "views" and "widgets" | | [Notice] assets cannot inherit. | */ 'inherit' => null, //default /* |-------------------------------------------------------------------------- | Listener from events |-------------------------------------------------------------------------- | | You can hook a theme when event fired on activities this is cool | feature to set up a title, meta, default styles and scripts. | | [Notice] these event can be override by package config. | */ 'events' => array( 'before' => function($theme) { $theme->setTitle('Title example'); $theme->setAuthor('Jonh Doe'); }, 'asset' => function($asset) { $asset->themePath()->add([ ['style', 'css/style.css'], ['script', 'js/script.js'] ]); // You may use elixir to concat styles and scripts. /* $asset->themePath()->add([ ['styles', 'dist/css/styles.css'], ['scripts', 'dist/js/scripts.js'] ]); */ // Or you may use this event to set up your assets. /* $asset->themePath()->add('core', 'core.js'); $asset->add([ ['jquery', 'vendor/jquery/jquery.min.js'], ['jquery-ui', 'vendor/jqueryui/jquery-ui.min.js', ['jquery']] ]); */ }, 'beforeRenderTheme' => function($theme) { // To render partial composer /* $theme->partialComposer('header', function($view){ $view->with('auth', Auth::user()); }); */ }, 'beforeRenderLayout' => array( 'mobile' => function($theme) { // $theme->asset()->themePath()->add('ipad', 'css/layouts/ipad.css'); } ) ) );
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/widget.blade.php
src/templates/widget.blade.php
<h1>{!! $label !!}</h1>
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/footer.blade.php
src/templates/footer.blade.php
<footer>Footer</footer>
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/templates/main.blade.php
src/templates/main.blade.php
<section id="main"> Main Section <small> [{!! protectEmail('email@example.com') !!}] </small> </section>
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Commands/ThemeGeneratorCommand.php
src/Commands/ThemeGeneratorCommand.php
<?php namespace Facuz\Theme\Commands; use Illuminate\Console\Command; use Illuminate\Config\Repository; use Illuminate\Filesystem\Filesystem as File; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class ThemeGeneratorCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'theme:create'; /** * The console command description. * * @var string */ protected $description = 'Generate theme structure.'; /** * Repository config. * * @var Illuminate\Config\Repository */ protected $config; /** * Filesystem * * @var Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new command instance. * * @param \Illuminate\Config\Repository $config * @param \Illuminate\Filesystem\Filesystem $files * @return \Facuz\Theme\Commands\ThemeGeneratorCommand */ public function __construct(Repository $config, File $files) { $this->config = $config; $this->files = $files; parent::__construct(); } /** * Execute the console command. * * @return void */ public function handle() { if ($this->files->isDirectory($this->getPath(null))){ return $this->error('Theme "'.$this->getTheme().'" is already exists.'); } $this->makeDirs([ 'assets/css', 'assets/js', 'assets/img', 'layouts', 'partials/sections', 'views', 'widgets', ]); $this->makeFiles([ 'layout.blade.php' => 'layouts/', 'header.blade.php' => 'partials/', 'footer.blade.php' => 'partials/', 'main.blade.php' => 'partials/sections/', 'index.blade.php' => 'views/', 'style.css' => 'assets/css/', 'script.js' => 'assets/js/', 'theme.json' => '', 'gulpfile.js' => '', 'config.php' => '' ]); $this->info('Theme "'.$this->getTheme().'" has been created.'); } /** * Make directory. * * @param array $directory * @return void */ protected function makeDirs($directory) { foreach ($directory as $path) { if (!$this->files->isDirectory($this->getPath($path))){ $this->files->makeDirectory($this->getPath($path), 0777, true); } } } /** * Make file. * * @param string $file * @param string $to * @return void */ protected function makeFiles($files) { foreach ($files as $file => $to) { $template = $this->getTemplate($file); $path = $to.$file; if (!$this->files->exists($this->getPath($path))){ $file_path = $this->getPath($path); $facade = $this->option('facade'); if (!is_null($facade)){ $template = preg_replace('/Theme(\.|::)/', $facade.'$1', $template); } $this->files->put($file_path, $template); if(substr($file_path, -10) == 'theme.json'){ $this->files->chmod($file_path, 0666); } } } } /** * Get root writable path. * * @param string $path * @return string */ protected function getPath($path) { $rootPath = $this->option('path'); return $rootPath.'/'.strtolower($this->getTheme()).'/' . $path; } /** * Get the theme name. * * @return string */ protected function getTheme() { return strtolower($this->argument('name')); } /** * Get default template. * * @param string $template * @return string */ protected function getTemplate($template) { $path = realpath(__DIR__.'/../templates/'.$template); return $this->files->get($path); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return array( array('name', InputArgument::REQUIRED, 'Name of the theme to generate.'), ); } /** * Get the console command options. * * @return array */ protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', null, InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path), array('facade', null, InputOption::VALUE_OPTIONAL, 'Facade name.', null), ); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Commands/ThemeListCommand.php
src/Commands/ThemeListCommand.php
<?php namespace Facuz\Theme\Commands; use Illuminate\Console\Command; use Illuminate\Config\Repository; use Illuminate\Filesystem\Filesystem as File; use Symfony\Component\Console\Input\InputOption; use Illuminate\Database\Eloquent\Collection; use Symfony\Component\Console\Input\InputArgument; use Facuz\Theme\Theme; class ThemeListCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'theme:list'; /** * The console command description. * * @var string */ protected $description = 'Show a list of all themes.'; /** * Repository config. * * @var Illuminate\Config\Repository */ protected $config; /** * Filesystem * * @var Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new command instance. * * @param \Illuminate\Config\Repository $config * @param \Illuminate\Filesystem\Filesystem $files * @return \Facuz\Theme\Commands\ThemeListCommand */ public function __construct(Repository $config, File $files) { $this->config = $config; $this->files = $files; parent::__construct(); } /** * Execute the console command. * * @return void */ public function handle() { $themes = []; $empty = true; $path = $this->option('path'); if ($this->files->exists($path)) { $scannedThemes = $this->files->directories($path); foreach ($scannedThemes as $key => $theme) { $themes[] = array($key+1, basename($theme)); $empty = false; } } $headers = ['#', 'Theme name']; if(!$empty){ $this->table($headers, $themes); } else { $this->info("No themes installed"); } } /** * Get root writable path. * * @param string $path * @return string */ protected function getPath($path) { $rootPath = $this->option('path'); return $rootPath.'/'.strtolower($this->getTheme()).'/' . $path; } /** * Get the theme name. * * @return string */ protected function getTheme() { return strtolower($this->argument('name')); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return array( //array('name', InputArgument::REQUIRED, 'Name of the theme to generate.'), ); } /** * Get the console command options. * * @return array */ protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', null, InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path) ); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Commands/ThemeDuplicateCommand.php
src/Commands/ThemeDuplicateCommand.php
<?php namespace Facuz\Theme\Commands; use Illuminate\Console\Command; use Illuminate\Config\Repository; use Illuminate\Filesystem\Filesystem as File; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class ThemeDuplicateCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'theme:duplicate'; /** * The console command description. * * @var string */ protected $description = 'Duplicate theme structure from other theme.'; /** * Repository config. * * @var Illuminate\Config\Repository */ protected $config; /** * Filesystem * * @var Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new command instance. * * @param \Illuminate\Config\Repository $config * @param \Illuminate\Filesystem\Filesystem $files * @return \Facuz\Theme\Commands\ThemeDuplicateCommand */ public function __construct(Repository $config, File $files) { $this->config = $config; $this->files = $files; parent::__construct(); } /** * Execute the console command. * * @return void */ public function handle() { $theme = strtolower($this->argument('name')); $new_theme = strtolower($this->argument('new-name')); $theme_path = $this->getPath($theme); $new_theme_path = $this->getPath($new_theme); if(!$this->files->isDirectory($theme_path)){ return $this->error('Theme "'.$theme.'" does not exist.'); } if($this->files->isDirectory($new_theme_path)){ return $this->error('Theme "'.$new_theme.'" is already exists.'); } $this->files->copyDirectory($theme_path, $new_theme_path); $this->info('Theme "'.$new_theme.'" has been created.'); } /** * Get root writable path. * * @param string $path * @return string */ protected function getPath($theme, $file = null) { $rootPath = $this->option('path'); return $rootPath.'/'.$theme.'/' . $file; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return array( array('name', InputArgument::REQUIRED, 'Name of the theme to duplicate.'), array('new-name', InputArgument::REQUIRED, 'Name of the new theme.'), ); } /** * Get the console command options. * * @return array */ protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', null, InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path), ); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Commands/WidgetGeneratorCommand.php
src/Commands/WidgetGeneratorCommand.php
<?php namespace Facuz\Theme\Commands; use Illuminate\Console\Command; use Illuminate\Config\Repository; use Illuminate\Filesystem\Filesystem as File; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class WidgetGeneratorCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'theme:widget'; /** * The console command description. * * @var string */ protected $description = 'Generate widget structure.'; /** * Widget view template global. * * @var boolean */ protected $global = false; /** * Repository config. * * @var Illuminate\Config\Repository */ protected $config; /** * Filesystem * * @var Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new command instance. * * @param \Illuminate\Config\Repository $config * @param \Illuminate\Filesystem\Filesystem $files * @return \Facuz\Theme\Commands\WidgetGeneratorCommand */ public function __construct(Repository $config, File $files) { $this->config = $config; $this->files = $files; parent::__construct(); } /** * Execute the console command. * * @return void */ public function handle() { // Widget class name is camel case. $widgetClassName = ucfirst($this->getWidgetName()); // Widget class file is camel with php extension. $widgetClassFile = $widgetClassName.'.php'; // CamelCase for template. $widgetClassTpl = lcfirst($this->getWidgetName()); // Get class template. $widgetClassTemplate = $this->getTemplate('widgetClass'); // Default create not on a global. $watch = 'false'; // If not specific a theme, not a global also return an error. if ($this->option('global') === false and ! $this->argument('theme')){ return $this->error('Please specific a theme name or use option -g to create as a global widget.'); } $theme_path = base_path($this->config->get('theme.themeDir').'/'.$this->getTheme()); if (is_dir($theme_path) === false){ return $this->error('The theme "'.$this->getTheme().'" does not exist.'); } // Create as a global use -g. if ($this->option('global') === true){ $watch = 'true'; } $widgetNamespace = $this->config->get('theme.namespaces.widget'); // Prepare class template. $widgetClassTemplate = preg_replace( array('|\{widgetNamespace\}|', '|\{widgetClass\}|', '|\{widgetTemplate\}|', '|\{watch\}|'), array($widgetNamespace, $widgetClassName, $widgetClassTpl, $watch), $widgetClassTemplate ); // Create widget directory. if (!$this->files->isDirectory(app_path().'/Widgets')){ $this->files->makeDirectory(app_path().'/Widgets', 0777, true); } // Widget class already exists. if ($this->files->exists(app_path().'/Widgets/'.$widgetClassFile)){ return $this->error('Widget "'.$this->getWidgetName().'" is already exists.'); } // Create class file. $this->files->put(app_path().'/Widgets/'.$widgetClassFile, $widgetClassTemplate); // Make file example. $this->makeFile('widgets/'.$widgetClassTpl.'.blade.php', $this->getTemplate('widget.blade')); $this->info('Widget "'.$this->getWidgetName().'" has been created.'); } /** * Make file. * * @param string $file * @param string $template * @return void */ protected function makeFile($file, $template = null) { $dirname = dirname($this->getPath($file)); // Checking directory. if (!$this->argument('theme') and ! $this->files->isDirectory($dirname)){ $this->files->makeDirectory($dirname, 0777, true); } if (!$this->files->exists($this->getPath($file))){ $this->files->put($this->getPath($file), $template); } } /** * Get root writable path. * * @param string $path * @return string */ protected function getPath($path) { // If not specific theme name, so widget will creating as global. if (!$this->argument('theme')){ return base_path('resources/views/'.$path); } $rootPath = $this->option('path'); return $rootPath.'/'.$this->getTheme().'/' . $path; } /** * Get the widget name. * * @return string */ protected function getWidgetName() { // The first character must be lower. return ucfirst($this->argument('name')); } /** * Get the theme name. * * @return string */ protected function getTheme() { return strtolower($this->argument('theme')); } /** * Get default template. * * @param string $template * @return string */ protected function getTemplate($template) { $path = realpath(__DIR__.'/../templates/'.$template.'.php'); return $this->files->get($path); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return array( array('name', InputArgument::REQUIRED, 'Name of the widget to generate.'), array('theme', InputArgument::OPTIONAL, 'Theme name to generate widget view file.') ); } /** * Get the console command options. * * @return array */ protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', 'p', InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path), array('global', 'g', InputOption::VALUE_NONE, 'Create global widget.', null) ); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/src/Commands/ThemeDestroyCommand.php
src/Commands/ThemeDestroyCommand.php
<?php namespace Facuz\Theme\Commands; use Illuminate\Console\Command; use Illuminate\Config\Repository; use Illuminate\Filesystem\Filesystem as File; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class ThemeDestroyCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'theme:destroy'; /** * The console command description. * * @var string */ protected $description = 'Remove a theme.'; /** * Repository config. * * @var Illuminate\Config\Repository */ protected $config; /** * Filesystem * * @var Illuminate\Filesystem\Filesystem */ protected $files; /** * Create a new command instance. * * @param \Illuminate\Config\Repository $config * @param \Illuminate\Filesystem\Filesystem $files * @return \Facuz\Theme\Commands\ThemeDestroyCommand */ public function __construct(Repository $config, File $files) { $this->config = $config; $this->files = $files; parent::__construct(); } /** * Execute the console command. * * @return void */ public function handle() { // The theme is not exists. if ( ! $this->files->isDirectory($this->getPath(null))) { return $this->error('Theme "'.$this->getTheme().'" is not exists.'); } $themePath = $this->getPath(null); if ($this->confirm('Are you sure you want to permanently delete?')) { // Delete permanent. $this->files->deleteDirectory($themePath, false); $this->info('Theme "'.$this->getTheme().'" has been destroyed.'); } } /** * Get root writable path. * * @param string $path * @return string */ protected function getPath($path) { $rootPath = $this->option('path'); return $rootPath.'/'.strtolower($this->getTheme()).'/' . $path; } /** * Get the theme name. * * @return string */ protected function getTheme() { return strtolower($this->argument('name')); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return array( array('name', InputArgument::REQUIRED, 'Name of the theme to generate.'), ); } /** * Get the console command options. * * @return array */ protected function getOptions() { $path = base_path($this->config->get('theme.themeDir')); return array( array('path', null, InputOption::VALUE_OPTIONAL, 'Path to theme directory.', $path) ); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/tests/ThemeTest.php
tests/ThemeTest.php
<?php use PHPUnit_Framework_TestCase; class ThemeTest extends PHPUnit_Framework_TestCase { public function testUsingTheme() { return $this->assertTrue(true); } }
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
FaCuZ/laravel-theme
https://github.com/FaCuZ/laravel-theme/blob/534ca95975dd875056a08ed89316285d6214b00d/config/theme.php
config/theme.php
<?php use Opis\Closure\SerializableClosure; $function = function(){ //$theme->setTitle('Something in global.'); }; $themeSerialize=new SerializableClosure($function); $asset = function(){ //$theme->setTitle('Something in global.'); $asset->cook('backbone', function($asset) { $asset->add('backbone', '//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js'); $asset->add('underscorejs', '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js'); }); }; $assetSerialize=new SerializableClosure($asset); return array( /* |-------------------------------------------------------------------------- | Asset url path |-------------------------------------------------------------------------- | | The path to asset, this config can be cdn host. | eg. http://cdn.domain.com | */ 'assetUrl' => env('APP_ASSET_URL', '/'), /* |-------------------------------------------------------------------------- | Theme Default |-------------------------------------------------------------------------- | | If you don't set a theme when using a "Theme" class | the default theme will replace automatically. | */ 'themeDefault' => env('APP_THEME', 'default'), /* |-------------------------------------------------------------------------- | Layout Default |-------------------------------------------------------------------------- | | If you don't set a layout when using a "Theme" class | the default layout will replace automatically. | */ 'layoutDefault' => env('APP_THEME_LAYOUT', 'layout'), /* |-------------------------------------------------------------------------- | Path to lookup theme |-------------------------------------------------------------------------- | | The root path contains themes collections. | */ 'themeDir' => env('APP_THEME_DIR', 'public/themes'), /* |-------------------------------------------------------------------------- | Namespaces |-------------------------------------------------------------------------- | | Class namespace. | */ 'namespaces' => array( 'widget' => 'App\Widgets' ), /* |-------------------------------------------------------------------------- | View Fallback path |-------------------------------------------------------------------------- | | You can define a view fallback path that will be appended when the theme | doesn't have its view file. This is useful if you want to have a base | theme in different folder. | */ 'view_fallback' => '', /* |-------------------------------------------------------------------------- | Listener from events |-------------------------------------------------------------------------- | | You can hook a theme when event fired on activities this is cool | feature to set up a title, meta, default styles and scripts. | */ 'events' => array( // Before all event, this event will effect for global. 'before' =>$themeSerialize, // This event will fire as a global you can add any assets you want here. 'asset' =>$assetSerialize ), );
php
MIT
534ca95975dd875056a08ed89316285d6214b00d
2026-01-05T04:50:30.879703Z
false
zombor/KOstache
https://github.com/zombor/KOstache/blob/e9b1c79f0004c16f935f2f0a0278de2ccdf1ab07/classes/Kostache.php
classes/Kostache.php
<?php defined('SYSPATH') or die('No direct script access.'); class Kostache extends Kohana_Kostache { }
php
MIT
e9b1c79f0004c16f935f2f0a0278de2ccdf1ab07
2026-01-05T04:50:42.071561Z
false
zombor/KOstache
https://github.com/zombor/KOstache/blob/e9b1c79f0004c16f935f2f0a0278de2ccdf1ab07/classes/Kostache/Layout.php
classes/Kostache/Layout.php
<?php defined('SYSPATH') or die('No direct script access.'); class Kostache_Layout extends Kohana_Kostache_Layout { }
php
MIT
e9b1c79f0004c16f935f2f0a0278de2ccdf1ab07
2026-01-05T04:50:42.071561Z
false