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/migrations/v3/m151215_193220_alter_table__cms_content.php | src/migrations/v3/m151215_193220_alter_table__cms_content.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.08.2015
*/
use yii\db\Schema;
use yii\db\Migration;
use yii\helpers\Json;
class m151215_193220_alter_table__cms_content extends Migration
{
public function safeUp()
{
$this->addColumn('{{%cms_content}}', 'access_check_element', $this->string(1)->notNull()->defaultValue('N'));
}
public function safeDown()
{
echo "m151110_193220_alter_table__cms_content cannot be reverted.\n";
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/migrations/v3/m150608_114030_alter_table__cms_site_code_length.php | src/migrations/v3/m150608_114030_alter_table__cms_site_code_length.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 24.03.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150608_114030_alter_table__cms_site_code_length extends Migration
{
public function safeUp()
{
$this->execute("ALTER TABLE {{%cms_site}} CHANGE `code` `code` CHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
$this->execute("ALTER TABLE {{%cms_site_domain}} CHANGE `site_code` `site_code` CHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
$this->execute("ALTER TABLE {{%cms_tree}} CHANGE `site_code` `site_code` CHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
$this->execute("ALTER TABLE {{%cms_component_settings}} CHANGE `site_code` `site_code` CHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
}
public function down()
{
echo "m150608_114030_alter_table__cms_site_code_length cannot be reverted.\n";
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/migrations/v3/m160412_113837__drop_table__cms_tree_menu.php | src/migrations/v3/m160412_113837__drop_table__cms_tree_menu.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.08.2015
*/
use yii\db\Schema;
use yii\db\Migration;
use yii\helpers\ArrayHelper;
class m160412_113837__drop_table__cms_tree_menu extends Migration
{
public function safeUp()
{
$tableExist = $this->db->getTableSchema("{{%cms_tree_menu}}", true);
if ($tableExist)
{
$this->dropTable("{{%cms_tree_menu}}");
}
return true;
}
public function safeDown()
{
echo "m160412_113837__drop_table__cms_tree_menu cannot be reverted.\n";
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/migrations/v3/m140902_110812_create_storage_file_table.php | src/migrations/v3/m140902_110812_create_storage_file_table.php | <?php
use yii\db\Schema;
use yii\db\Migration;
class m140902_110812_create_storage_file_table extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%cms_storage_file}}", true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable("{{%cms_storage_file}}", [
'id' => Schema::TYPE_PK,
'src' => Schema::TYPE_STRING. '(255) NOT NULL',
'cluster_id' => Schema::TYPE_STRING. '(16) NULL',
'cluster_file' => Schema::TYPE_STRING. '(255) NULL',
'created_by' => Schema::TYPE_INTEGER . ' NULL',
'updated_by' => Schema::TYPE_INTEGER . ' NULL',
'created_at' => Schema::TYPE_INTEGER . ' NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NULL',
'size' => Schema::TYPE_BIGINT. '(32)',
'type' => Schema::TYPE_STRING. '(16)',
'mime_type' => Schema::TYPE_STRING. '(16)',
'extension' => Schema::TYPE_STRING. '(16)',
'original_name' => Schema::TYPE_STRING. '(255)', //оригинальное название файла
'name_to_save' => Schema::TYPE_STRING. '(32)', //оригинальное название файла
'name' => Schema::TYPE_STRING. '(255)', //название для отображения на странице
'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', //статус, активна некативна, удалено
'status_adult' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 0', //Возрастной статус 0 - не проверено, 1-для всех, 2-типо эротические материалы, 3-порно
'description_short' => Schema::TYPE_TEXT,
'description_full' => Schema::TYPE_TEXT,
//Если файл картинка, заполняем дополнительные сведения
'image_height' => Schema::TYPE_INTEGER . ' NULL',
'image_width' => Schema::TYPE_INTEGER . ' NULL',
'count_comment' => Schema::TYPE_INTEGER . ' NULL', //Количество комментариев
'count_subscribe' => Schema::TYPE_INTEGER . ' NULL', //Количество подписчиков
'users_subscribers' => Schema::TYPE_TEXT. ' NULL', //Пользователи которые подписались (их id через запятую)
'count_vote' => Schema::TYPE_INTEGER . ' NULL', //Количество голосов
'result_vote' => Schema::TYPE_INTEGER . ' NULL', //Результат голосования
'users_votes_up' => Schema::TYPE_TEXT. ' NULL', //Пользователи которые проголосовали +
'users_votes_down' => Schema::TYPE_TEXT. ' NULL', //Пользователи которые проголосовали -
'linked_to_model' => Schema::TYPE_STRING. '(255) NULL', //Коммент обязательно должен быть к кому то привязан
'linked_to_value' => Schema::TYPE_STRING. '(255) NULL', //Коммент обязательно должен быть к кому то привязан
'page_options' => Schema::TYPE_TEXT. ' NULL', //
], $tableOptions);
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD UNIQUE(src);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD UNIQUE(cluster_id, cluster_file);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(cluster_id);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(cluster_file);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(size);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(extension);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(status);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(status_adult);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(name_to_save);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(name);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(type);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(mime_type);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(image_height);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(image_width);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(count_comment);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(count_subscribe);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(count_vote);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(result_vote);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(linked_to_model);");
$this->execute("ALTER TABLE {{%cms_storage_file}} ADD INDEX(linked_to_value);");
$this->execute("ALTER TABLE {{%cms_storage_file}} COMMENT = 'Файл';");
$this->addForeignKey(
'storage_file_created_by', "{{%cms_storage_file}}",
'created_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'storage_file_updated_by', "{{%cms_storage_file}}",
'updated_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function down()
{
$this->dropForeignKey("storage_file_created_by", "{{%cms_storage_file}}");
$this->dropForeignKey("storage_file_updated_by", "{{%cms_storage_file}}");
$this->dropTable("{{%cms_storage_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/migrations/v3/m150519_123210_cms_alter_drop_publications_and_page_options.php | src/migrations/v3/m150519_123210_cms_alter_drop_publications_and_page_options.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 24.03.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150519_123210_cms_alter_drop_publications_and_page_options extends Migration
{
public function safeUp()
{
$this->execute("ALTER TABLE {{%cms_tree%}} DROP `page_options`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `page_options`;");
$tableExist = $this->db->getTableSchema("{{%cms_publication}}", true);
if ($tableExist)
{
$this->execute("DROP TABLE {{%cms_publication}}");
}
}
public function down()
{
echo "m150519_123210_cms_alter_drop_publications_and_page_options cannot be reverted.\n";
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/migrations/v3/m151030_173220_alter_table__cms_tree.php | src/migrations/v3/m151030_173220_alter_table__cms_tree.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.08.2015
*/
use yii\db\Schema;
use yii\db\Migration;
use yii\helpers\Json;
class m151030_173220_alter_table__cms_tree extends Migration
{
public function safeUp()
{
$this->addColumn('{{%cms_tree}}', 'redirect_tree_id', $this->integer());
$this->createIndex('redirect_tree_id', '{{%cms_tree}}', 'redirect_tree_id');
$this->addForeignKey(
'cms_tree__redirect_tree_id', "{{%cms_tree}}",
'redirect_tree_id', '{{%cms_tree}}', 'id', 'SET NULL', 'SET NULL'
);
}
public function safeDown()
{
echo "m151030_173220_alter_table__cms_tree cannot be reverted.\n";
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/migrations/v3/m141117_100557_create_teable_site.php | src/migrations/v3/m141117_100557_create_teable_site.php | <?php
/**
* m141117_100557_create_teable_site
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 16.11.2014
* @since 1.0.0
*/
use yii\db\Schema;
use yii\db\Migration;
/**
* Class m141109_100557_create_cms_site_table
*/
class m141117_100557_create_teable_site extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%cms_site}}", true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql')
{
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable('{{%cms_site}}', [
'id' => Schema::TYPE_PK,
'created_by' => Schema::TYPE_INTEGER . ' NULL',
'updated_by' => Schema::TYPE_INTEGER . ' NULL',
'created_at' => Schema::TYPE_INTEGER . ' NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NULL',
'host_name' => Schema::TYPE_STRING . '(255) NULL',
'name' => Schema::TYPE_STRING . '(255) NULL',
'description' => Schema::TYPE_TEXT . ' NULL',
'params' => Schema::TYPE_TEXT . ' NULL',
'cms_tree_id' => Schema::TYPE_INTEGER . ' NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%cms_site}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%cms_site}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%cms_site}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%cms_site}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%cms_site}} ADD UNIQUE(host_name);");
$this->execute("ALTER TABLE {{%cms_site}} ADD UNIQUE(cms_tree_id);");
$this->execute("ALTER TABLE {{%cms_site}} ADD INDEX(name);");
$this->execute("ALTER TABLE {{%cms_site}} COMMENT = 'Заргеистрированные сайты';");
$this->addForeignKey(
'cms_site_created_by', "{{%cms_site}}",
'created_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'cms_site_updated_by', "{{%cms_site}}",
'updated_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'cms_site_cms_tree_id', "{{%cms_site}}",
'cms_tree_id', '{{%cms_tree}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function down()
{
$this->dropForeignKey("cms_site_cms_tree_id", "{{%cms_site}}");
$this->dropForeignKey("cms_site_updated_by", "{{%cms_site}}");
$this->dropForeignKey("cms_site_created_by", "{{%cms_site}}");
$this->dropTable('{{%cms_site}}');
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/migrations/v3/m141231_100557_create_teable_cms_tree_menu.php | src/migrations/v3/m141231_100557_create_teable_cms_tree_menu.php | <?php
/**
* m141231_100557_create_teable_cms_tree_menu
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 31.12.2014
* @since 1.0.0
*/
use yii\db\Schema;
use yii\db\Migration;
/**
* Class m141231_100557_create_teable_cms_tree_menu
*/
class m141231_100557_create_teable_cms_tree_menu extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%cms_tree_menu}}", true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql')
{
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable('{{%cms_tree_menu}}', [
'id' => Schema::TYPE_PK,
'created_by' => Schema::TYPE_INTEGER . ' NULL',
'updated_by' => Schema::TYPE_INTEGER . ' NULL',
'created_at' => Schema::TYPE_INTEGER . ' NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NULL',
'name' => Schema::TYPE_STRING . '(255) NOT NULL',
'description' => Schema::TYPE_TEXT . ' NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%cms_tree_menu}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%cms_tree_menu}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%cms_tree_menu}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%cms_tree_menu}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%cms_tree_menu}} ADD UNIQUE(name);");
$this->execute("ALTER TABLE {{%cms_tree_menu}} COMMENT = 'Позиции меню';");
$this->addForeignKey(
'cms_tree_menu_created_by', "{{%cms_tree_menu}}",
'created_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'cms_tree_menu_updated_by', "{{%cms_tree_menu}}",
'updated_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function down()
{
$this->dropForeignKey("cms_tree_menu_created_by", "{{%cms_tree_menu}}");
$this->dropForeignKey("cms_tree_menu_updated_by", "{{%cms_tree_menu}}");
$this->dropTable('{{%cms_tree_menu}}');
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/migrations/v3/m151221_093837_addI18nTables.php | src/migrations/v3/m151221_093837_addI18nTables.php | <?php
use yii\base\InvalidConfigException;
use yii\db\Migration;
use yii\db\Schema;
class m151221_093837_addI18nTables extends Migration
{
/**
* @return bool|void
* @throws InvalidConfigException
*/
public function safeUp()
{
$i18n = new \skeeks\cms\i18n\components\I18NDb();
if (!isset($i18n->sourceMessageTable) || !isset($i18n->messageTable)) {
throw new InvalidConfigException('You should configure i18n component');
}
$sourceMessageTable = $i18n->sourceMessageTable;
$messageTable = $i18n->messageTable;
$this->createTable($sourceMessageTable, [
'id' => Schema::TYPE_PK,
'category' => Schema::TYPE_STRING,
'message' => Schema::TYPE_TEXT
]);
$this->createTable($messageTable, [
'id' => Schema::TYPE_INTEGER,
'language' => Schema::TYPE_STRING,
'translation' => Schema::TYPE_TEXT
]);
$this->addPrimaryKey('id', $messageTable, ['id', 'language']);
$this->addForeignKey('fk_source_message_message', $messageTable, 'id', $sourceMessageTable, 'id', 'cascade', 'restrict');
}
public function safeDown()
{
$i18n = new \skeeks\cms\i18n\components\I18NDb();
if (!isset($i18n->sourceMessageTable) || !isset($i18n->messageTable)) {
throw new InvalidConfigException('You should configure i18n component');
}
$this->dropTable($i18n->sourceMessageTable);
$this->dropTable($i18n->messageTable);
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/migrations/v3/m150520_133210_cms_alter_storage_files.php | src/migrations/v3/m150520_133210_cms_alter_storage_files.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 24.03.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150520_133210_cms_alter_storage_files extends Migration
{
public function safeUp()
{
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `status`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `status_adult`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `count_subscribe`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `users_subscribers`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `count_vote`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `result_vote`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `users_votes_up`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `users_votes_down`;");
$this->execute("ALTER TABLE {{%cms_storage_file%}} DROP `count_comment`;");
}
public function down()
{
echo "m150520_133210_cms_alter_storage_files cannot be reverted.\n";
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/migrations/v3/m150116_100559_alter_table_publications.php | src/migrations/v3/m150116_100559_alter_table_publications.php | <?php
/**
* m150116_100559_alter_table_publications
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 16.01.2015
* @since 1.0.0
*/
use yii\db\Schema;
use yii\db\Migration;
class m150116_100559_alter_table_publications extends Migration
{
public function up()
{
$this->addColumn('{{%cms_publication}}', 'tree_id', Schema::TYPE_INTEGER . ' NULL');
$this->execute("ALTER TABLE {{%cms_publication}} ADD INDEX(tree_id);");
$this->addForeignKey(
'cms_publication_tree_id_cms_tree', "{{%cms_publication}}",
'tree_id', '{{%cms_tree}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function down()
{
$this->dropForeignKey("cms_publication_tree_id_cms_tree", "{{%cms_publication}}");
$this->dropColumn('{{%cms_publication}}', 'tree_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/migrations/v3/m150923_133220_create_table__cms_tree_image.php | src/migrations/v3/m150923_133220_create_table__cms_tree_image.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.08.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150923_133220_create_table__cms_tree_image extends Migration
{
public function safeUp()
{
$tableExist = $this->db->getTableSchema("{{%cms_tree_image}}", true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable("{{%cms_tree_image}}", [
'id' => $this->primaryKey(),
'created_by' => $this->integer(),
'updated_by' => $this->integer(),
'created_at' => $this->integer(),
'updated_at' => $this->integer(),
'storage_file_id' => $this->integer()->notNull(),
'tree_id' => $this->integer()->notNull(),
'priority' => $this->integer()->notNull()->defaultValue(100),
], $tableOptions);
$this->createIndex('updated_by', '{{%cms_tree_image}}', 'updated_by');
$this->createIndex('created_by', '{{%cms_tree_image}}', 'created_by');
$this->createIndex('created_at', '{{%cms_tree_image}}', 'created_at');
$this->createIndex('updated_at', '{{%cms_tree_image}}', 'updated_at');
$this->createIndex('storage_file_id', '{{%cms_tree_image}}', 'storage_file_id');
$this->createIndex('tree_id', '{{%cms_tree_image}}', 'tree_id');
$this->createIndex('priority', '{{%cms_tree_image}}', 'priority');
$this->createIndex('storage_file_id__tree_id', '{{%cms_tree_image}}', ['storage_file_id', 'tree_id'], true);
$this->execute("ALTER TABLE {{%cms_tree_image}} COMMENT = 'Связь разделов и файлов изображений';");
$this->addForeignKey(
'cms_tree_image_created_by', "{{%cms_tree_image}}",
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'cms_tree_image_updated_by', "{{%cms_tree_image}}",
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'cms_tree_image__storage_file_id', "{{%cms_tree_image}}",
'storage_file_id', '{{%cms_storage_file}}', 'id', 'CASCADE', 'CASCADE'
);
$this->addForeignKey(
'cms_tree_image__tree_id', "{{%cms_tree_image}}",
'tree_id', '{{%cms_tree}}', 'id', 'CASCADE', 'CASCADE'
);
}
public function safeDown()
{
$this->dropForeignKey("cms_tree_image_updated_by", "{{%cms_tree_image}}");
$this->dropForeignKey("cms_tree_image_updated_by", "{{%cms_tree_image}}");
$this->dropForeignKey("cms_tree_image__storage_file_id", "{{%cms_tree_image}}");
$this->dropForeignKey("cms_tree_image__tree_id", "{{%cms_tree_image}}");
$this->dropTable("{{%cms_tree_image}}");
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/migrations/v3/m150707_114030_alter_table__big_text.php | src/migrations/v3/m150707_114030_alter_table__big_text.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 24.03.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150707_114030_alter_table__big_text extends Migration
{
public function safeUp()
{
$this->execute("ALTER TABLE {{%cms_component_settings}} CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_content_element}} CHANGE `description_short` `description_short` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_content_element}} CHANGE `description_full` `description_full` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_content_element}} CHANGE `files` `files` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_tree}} CHANGE `description_short` `description_short` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_tree}} CHANGE `description_full` `description_full` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_tree}} CHANGE `files` `files` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_content_property}} CHANGE `component_settings` `component_settings` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->execute("ALTER TABLE {{%cms_tree_type_property}} CHANGE `component_settings` `component_settings` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;");
$this->dropIndex('value', '{{%cms_content_element_property}}');
$this->dropIndex('value', '{{%cms_tree_property}}');
$this->execute("ALTER TABLE {{%cms_content_element_property}} CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
$this->execute("ALTER TABLE {{%cms_tree_property}} CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
}
public function down()
{
echo "m150707_114030_alter_table__big_text cannot be reverted.\n";
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/widgets/GridView.php | src/widgets/GridView.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 25.05.2015
*/
namespace skeeks\cms\widgets;
use skeeks\cms\backend\helpers\BackendUrlHelper;
use skeeks\cms\base\ActiveRecord;
use skeeks\cms\helpers\PaginationConfig;
use skeeks\cms\Skeeks;
use skeeks\cms\widgets\assets\GridViewAsset;
use skeeks\yii2\config\ConfigBehavior;
use skeeks\yii2\config\ConfigTrait;
use skeeks\yii2\form\fields\FieldSet;
use skeeks\yii2\form\fields\WidgetField;
use yii\base\Component;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\data\ArrayDataProvider;
use yii\data\DataProviderInterface;
use yii\db\ActiveQuery;
use yii\db\ActiveQueryInterface;
use yii\grid\Column;
use yii\grid\DataColumn;
use yii\helpers\ArrayHelper;
use yii\helpers\Inflector;
use yii\helpers\Json;
/**
* @property string $modelClassName; название класса модели с которой идет работа
* @property DataProviderInterface|ActiveDataProvider $dataProvider; готовый датапровайдер с учетом настроек виджета
* @property array $resultColumns; готовый конфиг для построения колонок
* @property PaginationConfig $paginationConfig;
*
* Class ShopProductFiltersWidget
* @package skeeks\cms\cmsWidgets\filters
*/
class GridView extends \yii\grid\GridView
{
use ConfigTrait;
/**
* @var
*/
public $modelClassName;
/**
* @var array по умолчанию включенные колонки
*/
public $visibleColumns = [];
/**
* @var bool генерировать колонки по названию модели автоматически
*/
//public $isEnabledAutoColumns = true;
/**
* @var array
*/
public $autoColumns = [];
/**
* @var array
*/
public $disableAutoColumns = [];
/**
* @var array результирующий массив конфига колонок
*/
protected $_preInitColumns = [];
/**
* @var array автоматически созданные колонки
*/
protected $_autoColumns = [];
/**
* @var array
*/
public $configBehaviorData = [];
/**
* @var string name of the parameter storing the current page index.
* @see params
*/
public $pageParam = 'page';
/**
* @var string name of the parameter storing the page size.
* @see params
*/
public $pageSizeParam = 'per-page';
/**
* @var int the default page size. This property will be returned by [[pageSize]] when page size
* cannot be determined by [[pageSizeParam]] from [[params]].
*/
public $defaultPageSize = 20;
/**
* @var array|false the page size limits. The first array element stands for the minimal page size, and the second
* the maximal page size. If this is false, it means [[pageSize]] should always return the value of [[defaultPageSize]].
*/
public $pageSizeLimitMin = 1;
/**
* @var int
*/
public $pageSizeLimitMax = 50;
/**
* @var array
*/
public $defaultOrder = [];
/**
* @var array
*/
public $sortAttributes = [];
/**
* @var array Additional information in the context of a call widget
*/
public $contextData = [];
/**
* @param $value
* @return bool
* @deprecated
*/
public function setIsEnabledAutoColumns($value)
{
$this->autoColumns = $value;
return false;
}
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), [
ConfigBehavior::class => ArrayHelper::merge([
'class' => ConfigBehavior::class,
'configModel' => [
/*'on load' => function(Event $event) {
print_r($event->data);die;
$this->paginationConfig->load($event->data);
$this->paginationConfigArray = $this->paginationConfig->toArray();
},*/
'fields' => [
'main' => [
'class' => FieldSet::class,
'name' => \Yii::t('skeeks/cms', 'Main'),
'fields' => [
//'caption',
'visibleColumns' => [
'class' => WidgetField::class,
'widgetClass' => DualSelect::class,
'widgetConfig' => [
'visibleLabel' => \Yii::t('skeeks/cms', 'Display columns'),
'hiddenLabel' => \Yii::t('skeeks/cms', 'Hidden columns'),
],
//'multiple' => true,
'on beforeRender' => function ($e) {
/**
* @var $widgetField WidgetField
*/
$widgetField = $e->sender;
$fields = $this->getAvailableColumns(\Yii::$app->controller->getCallableData());
$widgetField->widgetConfig['items'] = $this->getFilteredAvailableColumns($fields, \Yii::$app->controller->getCallableData());
//skeeks\cms\backend\controllers\AdminBackendShowingController
/*$widgetField->widgetConfig['items'] = ArrayHelper::getValue(
\Yii::$app->controller->getCallableData(),
'availableColumns'
);*/
},
],
],
],
/*'sort' => [
'class' => FieldSet::class,
'name' => \Yii::t('skeeks/cms', 'Sorting'),
'fields' => [
'defaultOrder' => [
'class' => WidgetField::class,
'widgetClass' => SortSelect::class,
'on beforeRender' => function ($e) {
/**
* @var $widgetField WidgetField
$widgetField = $e->sender;
$widgetField->widgetConfig['items'] = ArrayHelper::getValue(
\Yii::$app->controller->getCallableData(),
'sortAttributes'
);
},
],
],
],*/
'paginationConfig' => [
'class' => FieldSet::class,
'name' => \Yii::t('skeeks/cms', 'Pagination'),
'fields' => [
'defaultPageSize' => [
'elementOptions' => [
'type' => 'number',
],
],
'pageSizeLimitMin' => [
'elementOptions' => [
'type' => 'number',
],
],
'pageSizeLimitMax' => [
'elementOptions' => [
'type' => 'number',
],
],
/*'pageParam',
'pageSizeParam',*/
],
],
],
'attributeDefines' => [
'visibleColumns',
'caption',
'pageParam',
'defaultPageSize',
'pageSizeLimitMin',
'pageSizeLimitMax',
'pageSizeParam',
'defaultOrder',
],
'attributeLabels' => [
'visibleColumns' => 'Отображаемые колонки',
'caption' => 'Заголовок таблицы',
'pageParam' => \Yii::t('skeeks/cms', 'Parameter name pages, pagination'),
'defaultPageSize' => \Yii::t('skeeks/cms', 'Number of records on one page'),
'pageSizeLimitMin' => \Yii::t('skeeks/cms', 'The minimum allowable value for pagination'),
'pageSizeLimitMax' => \Yii::t('skeeks/cms', 'The maximum allowable value for pagination'),
'pageSizeParam' => \Yii::t('skeeks/cms', 'pageSizeParam'),
'defaultOrder' => 'Сортировка',
],
'rules' => [
['visibleColumns', 'required'],
['visibleColumns', 'safe'],
['defaultOrder', 'safe'],
['caption', 'string'],
[['pageParam', 'pageSizeParam', 'defaultPageSize'], 'required'],
[['pageParam', 'pageSizeParam'], 'string'],
['defaultPageSize', 'integer'],
['pageSizeLimitMin', 'integer'],
['pageSizeLimitMax', 'integer'],
],
],
], (array)$this->configBehaviorData),
]);
}
/**
* @param $callableData
* @return array
*/
public function getAvailableColumns($callableData)
{
return (array)ArrayHelper::getValue(
$callableData,
'availableColumns'
);
}
/**
* @param $fields
* @return array
*/
public function getFilteredAvailableColumns($fields, $callableData)
{
$result = [];
$autoFilters = (array) ArrayHelper::getValue($callableData, 'callAttributes.autoColumns');
$disableAutoFilters = (array) ArrayHelper::getValue($callableData, 'callAttributes.disableAutoColumns');
foreach ($fields as $key => $value) {
if (is_array($autoFilters) && $autoFilters && !in_array($key, $autoFilters)) {
continue;
}
if (in_array($key, $disableAutoFilters)) {
continue;
}
$result[$key] = $value;
}
return $result;
}
public function getColumnsKeyLabels()
{
$result = [];
foreach ($this->_preInitColumns as $code => $column) {
$attribute = '';
$label = '';
if (is_array($column)) {
if (ArrayHelper::getValue($column, 'label')) {
if (ArrayHelper::getValue($column, 'label') !== false) {
$label = ArrayHelper::getValue($column, 'label');
}
} elseif (ArrayHelper::getValue($column, 'attribute')) {
$attribute = ArrayHelper::getValue($column, 'attribute');
}
} else {
$attribute = $code;
}
if ($label) {
$result[$code] = $label;
} elseif ($attribute) {
$provider = $this->dataProvider;
if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
/* @var $model Model */
$model = new $provider->query->modelClass;
$label = $model->getAttributeLabel($attribute);
} else {
$models = $provider->getModels();
if (($model = reset($models)) instanceof Model) {
/* @var $model Model */
$label = $model->getAttributeLabel($attribute);
} else {
$label = Inflector::camel2words($attribute);
}
}
if ($result && in_array($label, array_values($result))) {
$result[$code] = $label." ({$code})";
} else {
$result[$code] = $label;
}
} else {
$result[$code] = Inflector::camel2words($code);
}
}
return $result;
}
/**
* @var null|callable
*/
public $columnConfigCallback = null;
/**
*
*/
public function init()
{
//Создание датапровайдера исходя из настроек вызова виджета
if (!$this->dataProvider) {
$this->dataProvider = $this->_createDataProvider();
}
if (is_callable($this->dataProvider)) {
$callable = $this->dataProvider;
$this->dataProvider = call_user_func($callable, $this);
}
//Автомтическое конфигурирование колонок
$this->_initAutoColumns();
//Кое что для массового управления свойствами
$this->_initDialogCallbackData();
//Получение настроек из хранилища
$this->trigger("beforeInit");
parent::init();
//Сбор результирующего конфига колонок
$this->_initConfigColumns();
/*print_r($this->visibleColumns);die;*/
//Конфиг некоторых колонок включается только если они вообще включены
//Используется $columnConfigCallback
$this->_initDynamycColumns();
//И создание объектов колонок
$this->afterInitColumns();
//Правильно формирование колонок согласно настройкам
$this->_applyColumns();
//Инициализация постраничной навигации и возможных сортировок
$this->_initPagination();
$this->_initSort();
//Если удалили колонки
foreach ($this->columns as $key => $column) {
if (!is_object($column)) {
unset($this->columns[$key]);
}
}
}
protected function initColumns() {
return $this;
}
/**
* Creates column objects and initializes them.
*/
protected function afterInitColumns()
{
if (empty($this->columns)) {
$this->guessColumns();
}
if ($callbackEventName = BackendUrlHelper::createByParams()->setBackendParamsByCurrentRequest()->callbackEventName) {
$this->visibleColumns = ArrayHelper::merge([
"sx-choose"
], (array) $this->visibleColumns);
}
foreach ($this->columns as $i => $column) {
if ($this->visibleColumns && !in_array($i, $this->visibleColumns)) {
unset($this->columns[$i]);
continue;
}
if (is_string($column)) {
$column = $this->createDataColumn($column);
} else {
if (isset($column['beforeCreateCallback'])) {
if (is_callable($column['beforeCreateCallback'])) {
call_user_func($column['beforeCreateCallback'], $this);
}
unset($column['beforeCreateCallback']);
}
$column = \Yii::createObject(array_merge([
'class' => $this->dataColumnClass ?: DataColumn::className(),
'grid' => $this,
], $column));
}
if (!$column->visible) {
unset($this->columns[$i]);
continue;
}
$this->columns[$i] = $column;
}
}
public $exportParam = '_sx-export';
public $exportFileName = 'export';
public function run()
{
if (\Yii::$app->request->get($this->exportParam) == $this->id) {
Skeeks::unlimited();;
ob_clean();
$out = fopen('php://output', 'w');
foreach ($this->columns as $column) {
/* @var $column DataColumn */
$cells[] = iconv("UTF-8", "windows-1251//IGNORE", (string)strip_tags((string)$column->renderHeaderCell()));
}
fputcsv($out, $cells, ";");
if (isset($this->dataProvider->query)) {
foreach ($this->dataProvider->query->each(10) as $key => $model) {
$cells = [];
foreach ($this->columns as $column) {
if (method_exists($column, "renderDataCellContentForExport")) {
$cells[] = iconv("UTF-8", "windows-1251//IGNORE", strip_tags($column->renderDataCellContentForExport($model, $key, $key)));
} else {
$cells[] = iconv("UTF-8", "windows-1251//IGNORE", strip_tags($column->renderDataCell($model, $key, $key)));
}
}
fputcsv($out, $cells, ";");
}
}
fclose($out);
$filename = $this->exportFileName . ".csv";
header('Content-Type: text/csv');
// disable caching
$now = gmdate("D, d M Y H:i:s");
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
header("Last-Modified: {$now} GMT");
// force download
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment;filename='.$filename);
\Yii::$app->end();
}
GridViewAsset::register($this->view);
return parent::run();
}
protected function _initDialogCallbackData()
{
if ($callbackEventName = BackendUrlHelper::createByParams()->setBackendParamsByCurrentRequest()->callbackEventName) {
$isCkeditor = (int) \Yii::$app->request->get("CKEditorFuncNum");
$jsData = Json::encode(['is_ckeditor' => $isCkeditor]);
$this->view->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.SelectCmsElement = sx.classes.Component.extend({
_onDomReady: function()
{
var self = this;
$('table tr').on('dblclick', function()
{
$(".sx-row-action", $(this)).click();
return false;
});
$('table tr .sx-row-action').on('click', function()
{
self.submit($(this).data());
$(this).empty().append('<i class="fas fa-check"></i> Выбрано');
$(this).addClass("btn-primary");
return false;
});
},
submit: function(data)
{
if (this.get("is_ckeditor")) {
sx.EventManager.trigger('submitElement', data);
if (window.opener) {
if (window.opener.CKEDITOR) {
window.opener.CKEDITOR.tools.callFunction(self.get("is_ckeditor"), data.basenamesrc);
window.close();
}
}
} else {
sx.Window.openerWidgetTriggerEvent('{$callbackEventName}', data);
}
/*this.trigger("submit", data);
sx.EventManager.trigger('submitElement', data);
console.log('submit');*/
/*
if (window.opener)
{
if (window.opener.sx)
{
window.opener.sx.EventManager.trigger('{$callbackEventName}', data);
return this;
}
} else if (window.parent)
{
if (window.parent.sx)
{
window.parent.sx.EventManager.trigger('{$callbackEventName}', data);
return this;
}
}*/
return this;
}
});
sx.SelectCmsElement = new sx.classes.SelectCmsElement({$jsData});
})(sx, sx.$, sx._);
JS
);
$this->columns = ArrayHelper::merge([
'sx-choose' => $this->getDialogCallbackDataColumn(),
], $this->columns);
if ($this->visibleColumns) {
$this->visibleColumns = ArrayHelper::merge(['sx-choose'], $this->visibleColumns);
}
}
}
/**
* @param DataProviderInterface $dataProvider
* @return $this
*/
protected function _initPagination()
{
$dataProvider = $this->dataProvider;
$dataProvider->getPagination()->defaultPageSize = $this->defaultPageSize;
$dataProvider->getPagination()->pageParam = $this->pageParam;
$dataProvider->getPagination()->pageSizeParam = $this->pageSizeParam;
$dataProvider->getPagination()->pageSizeLimit = [
(int)$this->pageSizeLimitMin,
(int)$this->pageSizeLimitMax,
];
return $this;
}
/**
* @param DataProviderInterface $dataProvider
* @return $this
*/
protected function _initSort()
{
$dataProvider = $this->dataProvider;
$dataProvider->getSort()->attributes = ArrayHelper::merge($dataProvider->getSort()->attributes, $this->sortAttributes);
//Бывает ситуация когда сохранили настройки сортировки а потом удалил поля и забыз и как таковых атрибутов для сортировки уже нет
if ($this->defaultOrder && is_array($this->defaultOrder)) {
foreach ($this->defaultOrder as $key => $value)
{
if (!isset($dataProvider->getSort()->attributes[$key])) {
unset($this->defaultOrder[$key]);
}
}
}
$dataProvider->getSort()->defaultOrder = $this->defaultOrder;
return $this;
}
/**
* @return ActiveDataProvider
*/
protected function _createDataProvider()
{
$modelClassName = $this->modelClassName;
if ($modelClassName) {
$query = $modelClassName::find()
->select([$modelClassName::tableName() . ".*"])
;
return new ActiveDataProvider([
'query' => $query,
]);
} else {
return new ArrayDataProvider([
'allModels' => [],
]);
}
}
/**
* This function tries to guess the columns to show from the given data
* if [[columns]] are not explicitly specified.
*/
protected function _initAutoColumns()
{
//Если автоопределение колонок не включено
if ($this->autoColumns === false) {
return $this;
}
$dataProvider = clone $this->dataProvider;
$models = $dataProvider->getModels();
/**
* @var $model ActiveQuery
*/
$model = reset($models);
if (!$model) {
if ($dataProvider && isset($dataProvider->query) && $dataProvider->query->modelClass) {
$modelClass = $dataProvider->query->modelClass;
$model = new $modelClass();
}
}
if (is_array($model) || is_object($model)) {
foreach ($model as $name => $value) {
if ($value === null || is_scalar($value) || is_callable([$value, '__toString'])) {
$key = $name;
if (!empty($key) && strcasecmp($key, 'id')) {
if (substr_compare($key, 'id', -2, 2, true) === 0) {
$key = rtrim(substr($key, 0, -2), '_');
} elseif (substr_compare($key, 'id', 0, 2, true) === 0) {
$key = ltrim(substr($key, 2, strlen($key)), '_');
}
}
$keyMany = Inflector::pluralize($key);
$keyName = lcfirst(Inflector::id2camel($key, '_'));
$keyManyName = lcfirst(Inflector::id2camel($keyMany, '_'));
if ($model instanceof Component && $model->hasProperty($keyName)) {
$this->_autoColumns[(string)$name] = [
'attribute' => $name,
'format' => 'raw',
'value' => function ($model, $key, $index) use ($name, $keyName) {
return $model->{$keyName};
},
];
} else if ($model instanceof Component && $model->hasProperty(lcfirst($keyManyName))) {
$this->_autoColumns[(string)$name] = [
'attribute' => $name,
'format' => 'raw',
'value' => function ($model, $key, $index) use ($name, $keyManyName) {
return count($model->{$keyManyName});
},
];
} else {
$this->_autoColumns[(string)$name] = [
'attribute' => $name,
'format' => 'raw',
'value' => function ($model, $key, $index) use ($name) {
if (is_array($model)) {
$v = $model[$name];
} else {
$v = $model->{$name};
}
if (is_array($v)) {
return implode(",", $v);
} else {
return $v;
}
},
];
}
}
}
}
return $this;
}
/**
* @return $this
*/
protected function _initDynamycColumns() {
if ($this->columnConfigCallback && is_callable($this->columnConfigCallback)) {
$callback = $this->columnConfigCallback;
if ($this->visibleColumns && is_array($this->visibleColumns)) {
foreach ($this->visibleColumns as $columnCode)
{
if (!isset($this->columns[$columnCode])) {
$this->columns[$columnCode] = call_user_func($callback, $columnCode, $this);
}
}
}
}
return $this;
}
/**
* @return $this
*/
protected function _initConfigColumns()
{
$result = [];
$autoColumns = $this->_autoColumns;
$columns = $this->columns;
if ($columns) {
foreach ($columns as $key => $value) {
//Если с таким ключем есть автоколонка, нужно убрать ее из авто
if (is_string($key)) {
ArrayHelper::removeValue($autoColumns, $key);
}
if (is_string($value)) {
ArrayHelper::removeValue($autoColumns, $value);
$columns[$key] = [
'attribute' => $value,
];
}
if (is_array($value)) {
if ($attribute = ArrayHelper::getValue($value, 'attibute')) {
ArrayHelper::removeValue($autoColumns, $attribute);
}
}
}
}
$columnsTmp = (array)$columns;
$columns = ArrayHelper::merge((array)$autoColumns, (array)$columns);
foreach ($columns as $key => $config) {
$config['visible'] = true;
$columns[$key] = $config;
}
$resultColumns = [];
if ($columnsTmp) {
foreach ($columnsTmp as $key => $column) {
if (isset($columns[$key])) {
$resultColumns[$key] = $columns[$key];
unset($columns[$key]);
}
}
}
if ($resultColumns) {
$resultColumns = ArrayHelper::merge((array)$resultColumns, (array)$columns);
$columns = $resultColumns;
}
$this->_preInitColumns = $columns;
$this->columns = $this->_preInitColumns;
return $this;
}
protected function _applyColumns()
{
$result = [];
//Есть логика включенных выключенных колонок
if ($this->visibleColumns && $this->columns) {
foreach ($this->visibleColumns as $key) {
$result[$key] = ArrayHelper::getValue($this->columns, $key);
}
$this->columns = $result;
}
return $this;
}
/**
* @return array
*/
public function getCallableData()
{
$result = parent::getCallableData();
$result['resultColumns'] = $this->getColumnsKeyLabels();
$result['visibleColumns'] = $this->_getRealVisibleColumns();
return $result;
}
/**
* @return array
*/
protected function _getRealVisibleColumns()
{
$result = [];
foreach ($this->_preInitColumns as $key => $column) {
if (ArrayHelper::getValue($column, 'visible')) {
$result[] = $key;
}
}
return $result;
}
/**
* Данные необходимые для редактирования компонента, при открытии нового окна
* @return array
*/
public function getEditData()
{
$sort = [];
if ($this->dataProvider->getSort()->attributes) {
foreach ($this->dataProvider->getSort()->attributes as $key => $value) {
$sort[$key] = ArrayHelper::getValue($value, 'label');
}
}
return [
'callAttributes' => $this->callAttributes,
'availableColumns' => $this->getColumnsKeyLabels(),
'sortAttributes' => $sort,
];
}
protected $_dialogCallbackDataColumn = null;
/**
* @var null
*/
public $dialogCallbackData = null;
public function setDialogCallbackDataColumn($column)
{
$this->_dialogCallbackDataColumn = $column;
return $this;
}
public function getDialogCallbackDataColumn()
{
if ($this->_dialogCallbackDataColumn === null) {
$this->_dialogCallbackDataColumn = [
'class' => \yii\grid\DataColumn::className(),
'value' => function ($model) {
$data = $model->toArray();
if ($this->dialogCallbackData && is_callable($this->dialogCallbackData)) {
$callback = $this->dialogCallbackData;
$data = $callback($model);
} else {
if ($model instanceof ActiveRecord) {
$data = ArrayHelper::merge($model->toArray(), [
'asText' => $model->asText,
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | true |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/ContentElementBackendFiltersWidget.php | src/widgets/ContentElementBackendFiltersWidget.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\widgets;
use skeeks\cms\backend\actions\BackendGridModelAction;
use skeeks\cms\backend\widgets\FiltersWidget;
use skeeks\cms\models\CmsContent;
use skeeks\cms\models\CmsContentElement;
use skeeks\cms\models\CmsContentElementProperty;
use skeeks\cms\models\CmsContentProperty;
use skeeks\cms\models\CmsContentPropertyEnum;
use skeeks\cms\modules\admin\actions\modelEditor\AdminModelEditorAction;
use skeeks\cms\queryfilters\QueryFiltersEvent;
use skeeks\yii2\config\ConfigBehavior;
use skeeks\yii2\form\fields\BoolField;
use skeeks\yii2\form\fields\TextField;
use skeeks\yii2\form\fields\WidgetField;
use skeeks\yii2\queryfilter\QueryFilterWidget;
use yii\db\ActiveQuery;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class ContentElementBackendFiltersWidget extends FiltersWidget
{
public $disableAutoFilters = [
'updated_by',
'published_at',
'published_to',
'content_id',
'show_counter_start',
'description_short_type',
'description_full_type',
'images',
'imageIds',
'files',
'fileIds',
'main_cce_id',
'image_id',
'image_full_id',
'treeids',
];
public function init()
{
$this->fieldConfigCallback = function($code) {
if (strpos($code, "property") != -1) {
$propertyId = (int) str_replace("property", "", $code);
/**
* @var $property CmsContentProperty
*/
$property = CmsContentProperty::findOne($propertyId);
$result = [
'class' => TextField::class
];
if (!$property) {
return $result;
}
if ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_STRING) {
$result = [
'class' => TextField::class,
'label' => $property->name,
'on apply' => function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
*/
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"property_id" => $property->id,
])
->andWhere([
'like',
'value',
$e->field->value,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
},
];
} elseif ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_BOOL) {
$result = [
'class' => BoolField::class,
'label' => $property->name,
'on apply' => function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
*/
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"value_bool" => $e->field->value,
"property_id" => $property->id,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
},
];
} elseif ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_NUMBER) {
} elseif ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_LIST) {
$find = CmsContentPropertyEnum::find()->where(['property_id' => $property->id]);
$result = [
'label' => $property->name,
'class' => WidgetField::class,
'widgetClass' => AjaxSelect::class,
'widgetConfig' => [
'multiple' => true,
'ajaxUrl' => Url::to(['/cms/ajax/autocomplete-eav-options', 'property_id' => $property->id, 'cms_site_id' => \Yii::$app->skeeks->site->id]),
'valueCallback' => function ($value) {
return \yii\helpers\ArrayHelper::map(CmsContentPropertyEnum::find()->where(['id' => $value])->all(), 'id', 'value');
},
],
'on apply' => function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
*/
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"value_enum" => $e->field->value,
"property_id" => $property->id,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
}
];
/*$autoFilters["property{$property->id}"]['label'] = $property->name;
$autoFilters["property{$property->id}"]["on apply"] = function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"value_enum" => $e->field->value,
"property_id" => $property->id,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
};*/
} elseif ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_ELEMENT) {
$propertyType = $property->handler;
$find = CmsContentElement::find()->where(['content_id' => $propertyType->content_id]);
$result = [
'label' => $property->name,
'class' => WidgetField::class,
'widgetClass' => AjaxSelect::class,
'widgetConfig' => [
'multiple' => true,
'ajaxUrl' => Url::to(['/cms/ajax/autocomplete-eav-options', 'property_id' => $property->id, 'cms_site_id' => \Yii::$app->skeeks->site->id]),
'valueCallback' => function ($value) {
return \yii\helpers\ArrayHelper::map(CmsContentElement::find()->where(['id' => $value])->all(), 'id', 'name');
},
],
'on apply' => function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
*/
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"value_enum" => $e->field->value,
"property_id" => $property->id,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
}
];
/*$autoFilters["property{$property->id}"]["label"] = $property->name;
$autoFilters["property{$property->id}"]["on apply"] = function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"value_enum" => $e->field->value,
"property_id" => $property->id,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
};*/
} elseif ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_TREE) {
$propertyType = $property->handler;
$result = [
'class' => WidgetField::class,
'widgetClass' => \skeeks\cms\backend\widgets\SelectModelDialogTreeWidget::class,
'label' => $property->name,
'on apply' => function (QueryFiltersEvent $e) use ($property) {
/**
* @var $query ActiveQuery
*/
$query = $e->dataProvider->query;
if ($e->field->value) {
$query1 = CmsContentElementProperty::find()->select(['element_id as id'])
->where([
"value_enum" => $e->field->value,
"property_id" => $property->id,
]);
$query->andWhere([
CmsContentElement::tableName().".id" => $query1,
]);
}
},
];
}
return $result;
}
};
//$this->initFiltersModel();
parent::init();
}
/**
* @param $callableData
* @return array
*/
public function getAvailableFields($callableData)
{
$result = parent::getAvailableFields($callableData);
$content_id = ArrayHelper::getValue($callableData, 'callAttributes.contextData.content_id');
$cmsContent = CmsContent::findOne($content_id);
$properties = $cmsContent->getCmsContentProperties();
$properties->andWhere([
'or',
[CmsContentProperty::tableName().'.cms_site_id' => \Yii::$app->skeeks->site->id],
[CmsContentProperty::tableName().'.cms_site_id' => null],
]);
$properties = $properties->all();
/**
* @var CmsContentProperty $property
*/
foreach ($properties as $property) {
$result["property{$property->id}"] = $property->name;
}
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/widgets/ColorInput.php | src/widgets/ColorInput.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 21.07.2015
*/
namespace skeeks\cms\widgets;
use kartik\color\ColorInputAsset;
use yii\helpers\Html;
use yii\web\JsExpression;
/**
* Class ColorInput
* @package skeeks\cms\widgets
*/
class ColorInput extends \kartik\color\ColorInput
{
const SAVE_VALUE_TO_STRING = 'toString';
const SAVE_VALUE_TO_HEX = 'toHex';
const SAVE_VALUE_TO_HEX_STRING = 'toHexString';
const SAVE_VALUE_TO_RGB = 'toRgb';
const SAVE_VALUE_TO_RGB_STRING = 'toRgbString';
const SAVE_VALUE_TO_HSV = 'toHsv';
const SAVE_VALUE_TO_HSV_STRING = 'toHsvString';
const SAVE_VALUE_TO_HSL = 'toHsl';
const SAVE_VALUE_TO_HSL_STRING = 'toHslString';
const SAVE_VALUE_TO_NAME = 'toName';
/**
* @var array
*/
static public $possibleSaveAs =
[
self::SAVE_VALUE_TO_STRING => 'Стандартно — #ff0000',
//self::SAVE_VALUE_TO_HEX => 'toHex — ff0000',
self::SAVE_VALUE_TO_HEX_STRING => 'toHexString — #ff0000',
//self::SAVE_VALUE_TO_RGB => 'toRgb — {"r":255,"g":0,"b":0}',
self::SAVE_VALUE_TO_RGB_STRING => 'toRgbString — rgb(255, 0, 0)',
//self::SAVE_VALUE_TO_HSV => 'toHsv — {"h":0,"s":1,"v":1}',
self::SAVE_VALUE_TO_HSV_STRING => 'toHsvString — hsv(0, 100%, 100%)',
//self::SAVE_VALUE_TO_HSL => 'toHsl — {"h":0,"s":1,"l":0.5}',
self::SAVE_VALUE_TO_HSL_STRING => 'toHslString — hsl(0, 100%, 50%)',
self::SAVE_VALUE_TO_NAME => 'toName — red',
];
/**
*
*
* t.toHex() // "ff0000"
* t.toHexString() // "#ff0000"
* t.toRgb() // {"r":255,"g":0,"b":0}
* t.toRgbString() // "rgb(255, 0, 0)"
* t.toHsv() // {"h":0,"s":1,"v":1}
* t.toHsvString() // "hsv(0, 100%, 100%)"
* t.toHsl() // {"h":0,"s":1,"l":0.5}
* t.toHslString() // "hsl(0, 100%, 50%)"
* t.toName() // "red"
*
* @var string
*/
public $saveValueAs = self::SAVE_VALUE_TO_STRING;
/**
*
* Registers the needed assets
*/
public function registerAssets()
{
$view = $this->getView();
$value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
$this->html5Options['value'] = $value;
ColorInputAsset::register($view);
if ($this->useNative) {
parent::registerAssets();
return;
}
\kartik\base\Html5InputAsset::register($view);
$caption = 'jQuery("#' . $this->options['id'] . '")';
$input = 'jQuery("#' . $this->html5Options['id'] . '")';
$this->pluginOptions['change'] = new JsExpression("function(color){
_.delay(function()
{
{$caption}.val(color." . $this->saveValueAs . "());
}, 500);
}");
$this->registerPlugin('spectrum', $input);
$js = <<< JS
{$input}.spectrum('set','{$value}');
{$caption}.on('change', function(){
{$input}.spectrum('set',{$caption}.val());
});
JS;
$view->registerJs($js);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/PjaxLazyLoad.php | src/widgets/PjaxLazyLoad.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.12.2016
*/
namespace skeeks\cms\widgets;
/**
* @property bool isPjax;
*
* @package skeeks\cms\widgets
*/
class PjaxLazyLoad extends Pjax
{
/**
* @var int
*/
public $delay = 200;
public static $autoIdPrefix = 'PjaxLazyLoad';
/**
* @return bool
*/
public function getIsPjax() {
return $this->requiresPjax();
}
/**
* @return string|void
*/
public function run()
{
if (!$this->isPjax) {
\Yii::$app->view->registerJs(<<<JS
setTimeout(function() {
$.pjax.reload("#{$this->id}", {
'timeout': $this->timeout,
async: true
});
$.pjax.xhr = null;
}, $this->delay);
JS
);
}
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/widgets/Pjax.php | src/widgets/Pjax.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.12.2016
*/
namespace skeeks\cms\widgets;
/**
* Class Pjax
*
* @package skeeks\cms\widgets
*/
class Pjax extends \yii\widgets\Pjax
{
/**
* Block container Pjax
* @var bool
*/
public $isBlock = true;
/**
* @var bool
*/
public $isShowError = false;
/**
* @var bool
*/
public $isShowNotifyError = false;
/**
* Block other container
* @var string
*/
public $blockContainer = '';
/**
* @var int
*/
public $timeout = 30000;
/**
* @var string
*/
public $clientCallbackSend = "";
/**
* @var string
*/
public $clientCallbackComplete = "";
/**
* @var string
*/
public $clientCallbackError = "";
/**
* Registers the needed JavaScript.
*/
public function registerClientScript()
{
parent::registerClientScript();
$errorMessage = \Yii::t('skeeks/admin', 'An unexpected error occurred. Refer to the developers.');
$errorNotify = '';
$error = '';
if ($this->isShowNotifyError) {
$errorNotify = "sx.notify.error('{$errorMessage}:<br />' + data.responseText);";
}
if ($this->isShowError) {
$this->view->registerCss(<<<CSS
.pjax-errors {
background: #fee5e5;
padding: 15px;
margin-top: 10px;
border: 1px solid #f86c6b;
border-radius: 2px;
}
.pjax-errors .red {
color: red;
}
CSS
);
$error = "
var msg = '<span class=\"red\">{$errorMessage}</span><br />' + data.responseText;
var jPjax = $('#{$this->id}');
if ($('.pjax-errors', jPjax).length) {
$('.pjax-errors', jPjax).empty().append(msg);
} else {
$('<div>', {'class' : 'pjax-errors'}).appendTo(jPjax).append(msg);
}
";
}
if ($this->isBlock === true) {
$this->getView()->registerJs(<<<JS
(function(sx, $, _)
{
var blockerPanel = new sx.classes.Blocker('#{$this->id}');
$(document).on('pjax:send', function(e)
{
if ('{$this->id}' == e.target.id) {
//console.log('pjax:send');
blockerPanel = new sx.classes.Blocker($(e.target));
blockerPanel.block();
}
});
$(document).on('pjax:complete', function(e) {
if ('{$this->id}' == e.target.id) {
//console.log('pjax:complete');
blockerPanel.unblock();
}
});
$(document).on('pjax:end', function(e) {
if ('{$this->id}' == e.target.id) {
//console.log('pjax:end');
}
});
$(document).on('pjax:timeout', function(e) {
if ('{$this->id}' == e.target.id) {
//console.log('pjax:timeout');
}
});
$(document).on('pjax:success', function(e) {
if ('{$this->id}' == e.target.id) {
//console.log('pjax:success');
}
});
$(document).on('pjax:error', function(e, data) {
if ('{$this->id}' == e.target.id) {
//console.log('pjax:error');
//console.log(data);
{$errorNotify}
{$error}
blockerPanel.unblock();
e.preventDefault();
}
});
})(sx, sx.$, sx._);
JS
);
}
if ($this->blockContainer) {
$this->getView()->registerJs(<<<JS
(function(sx, $, _)
{
var blockerPanel = new sx.classes.Blocker($("{$this->blockContainer}"));
//console.log('blockContainer');
$(document).on('pjax:send', function(e)
{
if ('{$this->id}' == e.target.id) {
var blockerPanel = new sx.classes.Blocker($("{$this->blockContainer}"));
blockerPanel.block();
}
});
$(document).on('pjax:complete', function(e) {
if ('{$this->id}' == e.target.id) {
blockerPanel.unblock();
}
});
$(document).on('pjax:error', function(e, data) {
if ('{$this->id}' == e.target.id) {
{$errorNotify}
{$error}
blockerPanel.unblock();
e.preventDefault();
}
});
})(sx, sx.$, sx._);
JS
);
}
if ($this->clientCallbackSend) {
$clientCallbackSend = $this->clientCallbackSend;
$this->getView()->registerJs(<<<JS
//console.log('clientCallbackSend');
$(document).on('pjax:send', function(e, data)
{
var success = {$clientCallbackSend};
if ('{$this->id}' == e.target.id) {
success(e, data);
}
});
JS
);
}
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/DualSelect.php | src/widgets/DualSelect.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link https://skeeks.com/
* @copyright (c) 2010 SkeekS
* @date 24.03.2018
*/
namespace skeeks\cms\widgets;
use skeeks\cms\widgets\assets\DualSelectAsset;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\InputWidget;
/**
* Class SortableDualList
* @package skeeks\cms\widgets
*/
class DualSelect extends InputWidget
{
/**
* @var array
*/
public $wrapperOptions = [];
/**
* @var array
*/
public $items = [];
/**
* @var array
*/
public $jsOptions = [];
/**
* @var array|string
*/
public $visibleLabel = [
'tag' => 'h3',
'body' => 'Visibles'
];
/**
* @var array|string
*/
public $hiddenLabel = [
'tag' => 'h3',
'body' => 'Hiddens'
];
public $itemOptions = [
'tag' => 'li'
];
/**
* @inheritdoc
*/
public function run()
{
if (!$this->hasModel()) {
throw new InvalidConfigException('!!!');
}
Html::addCssClass($this->options, 'sx-select-element');
if (!ArrayHelper::getValue($this->options, 'id')) {
$this->options['id'] = Html::getInputId($model, $attribute);
$this->jsOptions['element_id'] = $this->options['id'];
}
$this->wrapperOptions['id'] = $this->id;
$this->jsOptions['id'] = $this->id;
$this->options['multiple'] = true;
$items = (array) $this->model->{$this->attribute};
$selectedItems = [];
if ($items) {
foreach ($items as $value)
{
$selectedItems[$value] = $value;
}
}
$element = Html::activeListBox($this->model, $this->attribute, (array) $selectedItems, $this->options);
echo $this->render('dual-select', [
'element' => $element,
]);
}
/**
* @param $value
* @param $item
*/
public function renderItem($value, $item)
{
$itemOptions = $this->itemOptions;
$tag = ArrayHelper::getValue($itemOptions, 'tag', 'li');
ArrayHelper::remove($itemOptions, 'tag');
$itemOptions['data']['value'] = $value;
echo Html::beginTag($tag, $itemOptions);
echo $item;
echo Html::endTag($tag);
}
/**
* @param $options
* @param string $defaultTab
* @return mixed
*/
public function renderHtml($options, $defaultTab = 'h3')
{
if (is_string($options)) {
return $this->renderHtml([
'body' => $options
]);
}
$tag = ArrayHelper::getValue($options, 'tag', $defaultTab);
ArrayHelper::remove($options, 'tag');
$body = ArrayHelper::getValue($options, 'body');
ArrayHelper::remove($options, 'body');
echo Html::beginTag($tag, $options);
echo $body;
echo Html::endTag($tag);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/SortSelect.php | src/widgets/SortSelect.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link https://skeeks.com/
* @copyright (c) 2010 SkeekS
* @date 24.03.2018
*/
namespace skeeks\cms\widgets;
use skeeks\cms\widgets\assets\DualSelectAsset;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\InputWidget;
/**
* Class SortableDualList
* @package skeeks\cms\widgets
*/
class SortSelect extends InputWidget
{
/**
* @var array
*/
public $wrapperOptions = [];
/**
* @var array
*/
public $items = [];
/**
* @var array
*/
public $jsOptions = [];
public $itemOptions = [
'tag' => 'li'
];
/**
* @inheritdoc
*/
public function run()
{
if (!$this->hasModel()) {
throw new InvalidConfigException('!!!');
}
Html::addCssClass($this->options, 'sx-select-element');
if (!ArrayHelper::getValue($this->options, 'id')) {
$this->options['id'] = Html::getInputId($model, $attribute);
$this->jsOptions['element_id'] = $this->options['id'];
}
$this->wrapperOptions['id'] = $this->id;
$this->jsOptions['id'] = $this->id;
$this->options['multiple'] = true;
$items = (array) $this->model->{$this->attribute};
$selectedItems = [];
if ($items) {
foreach ($items as $value)
{
$selectedItems[$value] = $value;
}
}
$element = Html::activeListBox($this->model, $this->attribute, (array) $selectedItems, $this->options);
echo $this->render('sort-select', [
'element' => $element,
]);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/StorageFileManager.php | src/widgets/StorageFileManager.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 12.04.2015
*/
namespace skeeks\cms\widgets;
use skeeks\cms\admin\assets\ActionFilesAsset;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
/**
* @property array $defaultClientOptions read-only
*
* Class ControllerActions
* @package skeeks\cms\modules\admin\widgets
* @deprecated
*/
class StorageFileManager extends Widget
{
const SOURCE_SIMPLE_UPLOAD = 'simpleUpload';
const SOURCE_REMOTE_UPLOAD = 'remoteUpload';
public $model;
/** @var array $targets */
public $clientOptions = [];
public $backendSimpleUploadUrl = '';
public $backendRemoteUploadUrl = '';
public $simpleUploadButtons = '';
public $remoteUploadButtonSelector = '';
public function init()
{
parent::init();
if (!$this->backendSimpleUploadUrl) {
$this->backendSimpleUploadUrl = Url::to(['/cms/admin-storage-files/upload']);
}
if (!$this->backendRemoteUploadUrl) {
$this->backendRemoteUploadUrl = Url::to(['/cms/admin-storage-files/remote-upload']);
}
$clientOptions = ArrayHelper::merge($this->defaultClientOptions, $this->clientOptions);
$options = [
'simpleUploadButtons' => [
'source-simpleUpload-' . $this->id,
'source-simpleUpload-2-' . $this->id,
],
'remoteUploadButtonSelector' => '.source-remoteUpload-' . $this->id,
'allUploadProgressSelector' => '.sx-progress-bar-' . $this->id,
'oneFileUploadProgressSelector' => '.sx-progress-bar-file-' . $this->id,
];
$clientOptions = ArrayHelper::merge($clientOptions, $options);
$clientOptionsString = \yii\helpers\Json::encode($clientOptions);
ActionFilesAsset::register($this->getView());
$fileManagerId = "sx-file-manager-{$this->id}";
$this->view->registerJs(<<<JS
(function(sx, $, _)
{
new sx.classes.CustomFileManager('#$fileManagerId', {$clientOptionsString});
})(sx, sx.$, sx._);
JS
);
}
public function run()
{
$str_upload = \Yii::t('skeeks/cms', 'Upload');
$str_togg_drop = \Yii::t('skeeks/cms', 'Toggle Dropdow');
$str_upl_from_comp = \Yii::t('skeeks/cms', 'Upload from your computer');
$str_remote_upl = \Yii::t('skeeks/cms', 'Upload by link {http}', ['http' => 'http://']);
$str_up_f = \Yii::t('skeeks/cms', 'The upload file');
$str_up_fs = \Yii::t('skeeks/cms', 'The upload files');
return <<<HTML
<div id="sx-file-manager-{$this->id}">
<div class="sx-upload-sources">
<div class="btn-group">
<button type="button" id="source-simpleUpload-{$this->id}" class="btn btn-secondary source-simpleUpload">
<i class="fas fa-download"></i> {$str_upload}
</button>
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">{$str_togg_drop}</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#" id="source-simpleUpload-2-{$this->id}" ><i class="glyphicon glyphicon-download-alt"></i> {$str_upl_from_comp}</a></li>
<li><a href="#" id="source-remoteUpload-{$this->id}" class="source-remoteUpload-{$this->id}" ><i class="glyphicon glyphicon-globe "></i> {$str_remote_upl}</a></li>
</ul>
</div>
</div>
<div class="sx-progress-bar-file-{$this->id}" style="display: none;">
<span style="vertical-align:middle;">{$str_up_f}: <span class="sx-uploaded-file-name"></span></span>
<div class="sx-progress-bar-wrapper">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-success"></div>
</div>
</div>
</div>
<div class="sx-progress-bar-{$this->id}" style="display: none;">
<span style="vertical-align:middle;">{$str_up_fs} (<span class="sx-uploadedFiles"></span> / <span class="sx-allFiles"></span>)</span>
<div class="sx-progress-bar-wrapper">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-success"></div>
</div>
</div>
</div>
</div>
HTML;
}
public function getDefaultClientOptions()
{
$result['simpleUpload']['options'] = $this->_getSourceSimpleUploadOptions();
$result['remoteUpload'] = $this->_getSourceRemoteUploadOptions();
return $result;
}
protected function _getSourceSimpleUploadOptions()
{
//Опции которые перетирать нельзя
$options =
[
"url" => $this->backendSimpleUploadUrl,
"name" => "imgfile", //TODO: хардкод
"hoverClass" => 'btn-hover',
"focusClass" => 'active',
"disabledClass" => 'disabled',
"responseType" => 'json',
"multiple" => true,
];
return $options;
}
protected function _getSourceRemoteUploadOptions()
{
$options =
[
"url" => $this->backendRemoteUploadUrl,
"name" => "imgfile", //TODO: хардкод
"hoverClass" => 'btn-hover',
"focusClass" => 'active',
"disabledClass" => 'disabled',
"responseType" => 'json',
"multiple" => true,
];
return $options;
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/ActiveFormModelPropertyValues.php | src/widgets/ActiveFormModelPropertyValues.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 18.03.2015
*/
namespace skeeks\cms\widgets;
use skeeks\cms\base\widgets\ActiveFormAjaxSubmit;
use skeeks\modules\cms\form\models\Form;
use yii\base\Model;
use yii\helpers\ArrayHelper;
/**
* Class ActiveForm
* @package skeeks\modules\cms\form\widgets
*/
class ActiveFormModelPropertyValues extends ActiveFormAjaxSubmit
{
/**
* @var Model
*/
public $modelWithProperties;
public function __construct($config = [])
{
$this->validationUrl = \skeeks\cms\helpers\UrlHelper::construct('/cms/model-properties/validate')->toString();
$this->action = \skeeks\cms\helpers\UrlHelper::construct('/cms/model-properties/submit')->toString();
$this->enableAjaxValidation = true;
parent::__construct($config);
}
public function init()
{
parent::init();
echo \yii\helpers\Html::hiddenInput("sx-model-value", $this->modelWithProperties->id);
echo \yii\helpers\Html::hiddenInput("sx-model", $this->modelWithProperties->className());
}
/**
*
* TODO: Вынести в трейт, используется для админки
* Стилизованный селект админки
*
* @param $model
* @param $attribute
* @param $items
* @param array $config
* @param array $fieldOptions
* @return \skeeks\cms\base\widgets\ActiveField
*/
public function fieldSelect($model, $attribute, $items, $config = [], $fieldOptions = [])
{
$config = ArrayHelper::merge(
['allowDeselect' => false],
$config,
[
'items' => $items,
]
);
/*foreach ($config as $key => $value) {
if (property_exists(Chosen::className(), $key) === false) {
unset($config[$key]);
}
}*/
return $this->field($model, $attribute, $fieldOptions)->widget(
Select::className(),
$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/widgets/Select2.php | src/widgets/Select2.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 25.05.2015
*/
namespace skeeks\cms\widgets;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class Select2 extends \kartik\select2\Select2
{
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/AjaxFileUploadWidget.php | src/widgets/AjaxFileUploadWidget.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link https://skeeks.com/
* @copyright (c) 2010 SkeekS
* @date 04.05.2017
*/
namespace skeeks\cms\widgets;
use skeeks\cms\models\CmsStorageFile;
use yii\helpers\Html;
/**
* Class AjaxFileUploadWidget
* @package skeeks\cms\widgets
*/
class AjaxFileUploadWidget extends \skeeks\yii2\ajaxfileupload\widgets\AjaxFileUploadWidget
{
protected function _initClientFiles()
{
if ($this->multiple) {
if (is_array($this->model->{$this->attribute})) {
foreach ($this->model->{$this->attribute} as $value) {
if ($file = CmsStorageFile::findOne((int)$value)) {
$this->clientOptions['files'][] = $this->_getCmsFileData($file);
} else {
if ($this->_getClientFileData($value)) {
$this->clientOptions['files'][] = $this->_getClientFileData($value);
}
}
}
}
} else {
if ($value = $this->model->{$this->attribute}) {
if ($file = CmsStorageFile::findOne((int)$value)) {
$this->clientOptions['files'][] = $this->_getCmsFileData($file);
} else {
return parent::_initClientFiles();
}
} else {
return parent::_initClientFiles();
}
}
return $this;
}
protected function _getCmsFileData(CmsStorageFile $file)
{
$fileData = [
'name' => $file->fileName,
'value' => $file->id,
'state' => 'success',
'size' => $file->size,
'sizeFormated' => \Yii::$app->formatter->asShortSize($file->size, 2),
'type' => $file->mime_type,
'src' => $file->src,
];
if ($file->isImage()) {
$fileData['image'] = [
'height' => $file->image_height,
'width' => $file->image_width,
];
$fileData['preview'] = Html::img($file->src);
}
return $fileData;
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/AjaxSelectModel.php | src/widgets/AjaxSelectModel.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 25.05.2015
*/
namespace skeeks\cms\widgets;
use yii\base\InvalidConfigException;
use yii\db\ActiveQuery;
/*
'modelClass' => CrmContractor::class,
'searchQuery' => function($word = '') {
$query = CrmContractor::find()->typeProject();
if ($word) {
$query->search($word);
}
return $query;
},
*/
/**
*
* @property ActiveQuery $searchQuery;
*
* @author Semenov Alexander <semenov@skeeks.com>
*/
class AjaxSelectModel extends AjaxSelect
{
/**
* @var null
*/
public $modelClass = null;
/**
* @var string
*/
public $modelPkAttribute = "id";
/**
* @var string
*/
public $modelShowAttribute = "asText";
/**
* @var int
*/
public $limit = 25;
/**
* @var null
*/
public $searchQuery = null;
/**
* @var array
*/
public $searchFields = ['id', 'name'];
/**
* @throws \ReflectionException
* @throws \yii\base\InvalidConfigException
*/
public function init()
{
$modelClass = $this->modelClass;
if (!$modelClass) {
throw new InvalidConfigException("modelClass is required");
}
if (!$this->valueCallback) {
$this->valueCallback = function ($value) use ($modelClass) {
return \yii\helpers\ArrayHelper::map($modelClass::find()->where([$this->modelPkAttribute => $value])->all(), $this->modelPkAttribute, $this->modelShowAttribute);
};
}
if (!$this->dataCallback) {
$this->dataCallback = function ($word = '') use ($modelClass) {
$query = $this->_createSearchQuery($word);
if (!$query->limit) {
$data = $query->limit($this->limit);
}
$data = $query->all();
$result = [];
/*if (!$this->isRequired()) {
$result[] = [
'id' => '',
'text' => 'Не выбрано',
];
}*/
if ($data) {
foreach ($data as $model) {
$result[] = [
'id' => $model->{$this->modelPkAttribute},
'text' => $model->{$this->modelShowAttribute},
];
}
}
return $result;
};
}
parent::init();
}
/**
* @return ActiveQuery|null
*/
protected function _createSearchQuery($word = '')
{
$modelClass = $this->modelClass;
if (is_callable($this->searchQuery)) {
$query = call_user_func($this->searchQuery, $word);
} else {
$query = $modelClass::find();
if ($word) {
if (method_exists($query, 'search')) {
$query->search($word);
} else {
if ($this->searchFields) {
$where = [];
$where[] = 'or';
foreach ($this->searchFields as $field)
{
$where[] = ['like', $field, $word];
}
$query->andWhere($where);
}
}
}
}
return $query;
}
/**
* @param $className
* @return $this
*/
public function setModelClassName($className)
{
$this->modelClass = $className;
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/widgets/AjaxSelect.php | src/widgets/AjaxSelect.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 25.05.2015
*/
namespace skeeks\cms\widgets;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\web\Application;
use yii\web\JsExpression;
/**
*
*
*
'dataCallback' => function($q = '') use ($content) {
$userIds = CmsContentElement::find()
->cmsSite()
->andWhere(['content_id' => $content->id])
->groupBy("created_by")
->select('created_by')
->asArray()
->indexBy("created_by")
->all()
;
$query = null;
if ($userIds) {
$userIds = array_keys($userIds);
$query = CmsUser::find()->where(['id' => $userIds]);
} else {
return [];
}
if ($q) {
$query->andWhere([
'or',
['like', 'first_name', $q],
['like', 'last_name', $q],
['like', 'email', $q],
['like', 'phone', $q],
]);
}
$data = $query->limit(50)
->all();
$result = [];
if ($data) {
foreach ($data as $model)
{
$result[] = [
'id' => $model->id,
'text' => $model->shortDisplayName
];
}
}
return $result;
},
'valueCallback' => function($value) {
return \yii\helpers\ArrayHelper::map(CmsUser::find()->where(['id' => $value])->all(), 'id', 'shortDisplayName');
},
* @author Semenov Alexander <semenov@skeeks.com>
*/
class AjaxSelect extends Select
{
public static $autoIdPrefix = "AjaxSelect";
/**
* @var callable
*/
public $dataCallback = null;
/**
* @var null
*/
public $ajaxUrl = null;
/**
* @var null
*/
public $valueCallback = null;
public function init()
{
$ajaxOptions = [];
if (isset($this->pluginOptions['ajax'])) {
$ajaxOptions = $this->pluginOptions['ajax'];
}
$this->pluginOptions['ajax'] = ArrayHelper::merge([
'url' => $this->ajaxUrl ? $this->ajaxUrl : Url::current(['ajaxid' => $this->id]),
//'url' => Url::to([\Yii::$app->controller->action->id, 'ajaxid' => $this->id]),
'dataType' => 'json',
'delay' => 250,
'cache' => true,
'data' => new JsExpression('function(params) { return {q:params.term}; }'),
], $ajaxOptions);
parent::init();
}
public function run() {
$callback = $this->dataCallback;
if ($callback && \Yii::$app->request->isAjax && \Yii::$app->request->get('ajaxid') == $this->id) {
\Yii::$app->on(Application::EVENT_AFTER_ACTION, function () use ($callback) {
ob_get_clean();
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$data['results'] = call_user_func($callback, \Yii::$app->request->get('q'));
\Yii::$app->response->data = $data;
\Yii::$app->end();
});
//ob_get_clean();
} elseif ($this->value && $this->valueCallback) {
$callback = $this->valueCallback;
$this->data = call_user_func($callback, $this->value);
}
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/widgets/ActiveFormRelatedProperties.php | src/widgets/ActiveFormRelatedProperties.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 18.03.2015
*/
namespace skeeks\cms\widgets;
use skeeks\cms\modules\admin\traits\ActiveFormTrait;
use skeeks\cms\modules\admin\traits\AdminActiveFormTrait;
use skeeks\cms\modules\admin\widgets\ActiveForm;
use skeeks\cms\traits\ActiveFormAjaxSubmitTrait;
use skeeks\modules\cms\form\models\Form;
use yii\base\Model;
/**
* Class ActiveFormRelatedProperties
* @package skeeks\cms\widgets
*/
class ActiveFormRelatedProperties extends ActiveForm
{
use AdminActiveFormTrait;
use ActiveFormAjaxSubmitTrait;
/**
* @var Model
*/
public $modelHasRelatedProperties;
public function __construct($config = [])
{
$this->validationUrl = \skeeks\cms\helpers\UrlHelper::construct('/cms/model-properties/validate')->toString();
$this->action = \skeeks\cms\helpers\UrlHelper::construct('/cms/model-properties/submit')->toString();
$this->enableAjaxValidation = true;
parent::__construct($config);
}
public function init()
{
parent::init();
echo \yii\helpers\Html::hiddenInput("sx-model-value", $this->modelHasRelatedProperties->id);
echo \yii\helpers\Html::hiddenInput("sx-model", $this->modelHasRelatedProperties->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/widgets/ContentElementBackendGridView.php | src/widgets/ContentElementBackendGridView.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\widgets;
use skeeks\cms\backend\actions\BackendGridModelAction;
use skeeks\cms\backend\widgets\FiltersWidget;
use skeeks\cms\backend\widgets\GridViewWidget;
use skeeks\cms\models\CmsContent;
use skeeks\cms\models\CmsContentElement;
use skeeks\cms\models\CmsContentElementProperty;
use skeeks\cms\models\CmsContentProperty;
use skeeks\cms\models\CmsContentPropertyEnum;
use skeeks\cms\modules\admin\actions\modelEditor\AdminModelEditorAction;
use skeeks\cms\queryfilters\QueryFiltersEvent;
use skeeks\yii2\config\ConfigBehavior;
use skeeks\yii2\form\fields\BoolField;
use skeeks\yii2\form\fields\TextField;
use skeeks\yii2\form\fields\WidgetField;
use skeeks\yii2\queryfilter\QueryFilterWidget;
use yii\db\ActiveQuery;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class ContentElementBackendGridView extends GridViewWidget
{
public function init()
{
$this->columnConfigCallback = function($code) {
if (strpos($code, "property") != -1) {
$propertyId = (int) str_replace("property", "", $code);
/**
* @var $property CmsContentProperty
*/
$property = CmsContentProperty::findOne($propertyId);
if (!$property) {
return [];
}
return [
'headerOptions' => [
'style' => 'width: 150px;'
],
'contentOptions' => [
'style' => 'width: 150px;'
],
'label' => $property ? $property->name : "Свойство удалено",
'format' => 'raw',
'value' => function ($model, $key, $index) use ($property) {
if (!$property) {
return '';
}
/**
* @var $model \skeeks\cms\models\CmsContentElement
*/
return $model->relatedPropertiesModel->getAttributeAsHtml($property->code);
},
];
return $result;
}
};
//$this->initFiltersModel();
parent::init();
}
/**
* @param $callableData
* @return array
*/
public function getAvailableColumns($callableData)
{
$result = parent::getAvailableColumns($callableData);
$content_id = ArrayHelper::getValue($callableData, 'callAttributes.contextData.content_id');
$cmsContent = CmsContent::findOne($content_id);
$properties = $cmsContent->getCmsContentProperties();
$properties->andWhere([
'or',
[CmsContentProperty::tableName().'.cms_site_id' => \Yii::$app->skeeks->site->id],
[CmsContentProperty::tableName().'.cms_site_id' => null],
]);
$properties = $properties->all();
/**
* @var CmsContentProperty $property
*/
foreach ($properties as $property) {
$result["property{$property->id}"] = $property->name;
}
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/widgets/Select.php | src/widgets/Select.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 25.05.2015
*/
namespace skeeks\cms\widgets;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;
use yii\web\View;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class Select extends Select2
{
protected $_isAutoDetectAutoDeselect = true;
protected $_defaultOptions = [];
/**
* @deprecated
* @var bool
*/
public $allowDeselect = true;
/**
* @var bool
*/
public $multiple = false;
/**
* @var string
*/
public $placeholder = '';
public function init()
{
if ($this->placeholder) {
$this->options['placeholder'] = $this->placeholder;
}
if ($this->multiple) {
$this->options['multiple'] = 'multiple';
}
if ($this->allowDeselect) {
if ($this->isRequired()) {
} else {
if (!isset($this->options['placeholder'])) {
$this->options['placeholder'] = '';
}
$this->pluginOptions['allowClear'] = true;
if (!$this->multiple) {
$this->data = ArrayHelper::merge(['' => ''], (array) $this->data);
}
}
}
parent::init();
}
/**
* @param $items
* @return $this
*/
public function setItems($items = [])
{
$this->data = $items;
return $this;
}
/**
* Registers the client assets for [[Select2]] widget.
*/
public function registerAssets()
{
$id = $this->options['id'];
$this->registerAssetBundle();
$isMultiple = isset($this->options['multiple']) && $this->options['multiple'];
$options = Json::encode([
'themeCss' => ".select2-container--{$this->theme}",
'sizeCss' => empty($this->addon) && $this->size !== self::MEDIUM ? ' input-' . $this->size : '',
'doReset' => static::parseBool($this->changeOnReset),
'doToggle' => static::parseBool($isMultiple && $this->showToggleAll),
'doOrder' => static::parseBool($isMultiple && $this->maintainOrder),
]);
$this->_s2OptionsVar = 's2options_' . hash('crc32', $options);
$this->options['data-s2-options'] = $this->_s2OptionsVar;
$view = $this->getView();
$view->registerJs("var {$this->_s2OptionsVar} = {$options};", View::POS_READY);
if ($this->maintainOrder) {
$val = Json::encode(is_array($this->value) ? $this->value : [$this->value]);
$view->registerJs("initS2Order('{$id}',{$val});");
}
$this->registerPlugin($this->pluginName, "jQuery('#{$id}')", "initS2Loading('{$id}','{$this->_s2OptionsVar}')");
}
/**
* Registers plugin options by storing within a uniquely generated javascript variable.
*
* @param string $name the plugin name
*/
protected function registerPluginOptions($name)
{
$this->hashPluginOptions($name);
$encOptions = empty($this->_encOptions) ? '{}' : $this->_encOptions;
$this->registerWidgetJs("window.{$this->_hashVar} = {$encOptions};\n", View::POS_READY);
}
/**
* @return bool
*/
protected function isRequired()
{
if (!empty($this->options['required'])) {
return true;
}
if (!$this->hasModel()) {
return false;
}
$validators = $this->model->getActiveValidators($this->attribute);
foreach ($validators as $validator) {
if ($validator instanceof RequiredValidator) {
if (is_callable($validator->when)) {
if (call_user_func($validator->when, $this->model, $this->attribute)) {
return true;
}
} else {
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/widgets/Alert.php | src/widgets/Alert.php | <?php
/**
* Alert
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 08.11.2014
* @since 1.0.0
*/
namespace skeeks\cms\widgets;
/**
* Alert widget renders a message from session flash. All flash messages are displayed
* in the sequence they were assigned using setFlash. You can set message as following:
*
* ```php
* \Yii::$app->getSession()->setFlash('error', 'This is the message');
* \Yii::$app->getSession()->setFlash('success', 'This is the message');
* \Yii::$app->getSession()->setFlash('info', 'This is the message');
* ```
*
* Multiple messages could be set as follows:
*
* ```php
* \Yii::$app->getSession()->setFlash('error', ['Error 1', 'Error 2']);
* ```
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @author Alexander Makarov <sam@rmcreative.ru>
*/
class Alert extends \yii\bootstrap\Widget
{
/**
* @var array the alert types configuration for the flash messages.
* This array is setup as $key => $value, where:
* - $key is the name of the session flash variable
* - $value is the bootstrap alert type (i.e. danger, success, info, warning)
*/
public $alertTypes = [
'error' => 'alert-danger',
'danger' => 'alert-danger',
'success' => 'alert-success',
'info' => 'alert-info',
'warning' => 'alert-warning'
];
/**
* @var array the options for rendering the close button tag.
*/
public $closeButton = [];
public function init()
{
parent::init();
$session = \Yii::$app->getSession();
$flashes = $session->getAllFlashes();
$appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
foreach ($flashes as $type => $data) {
if (isset($this->alertTypes[$type])) {
$data = (array)$data;
foreach ($data as $message) {
/* initialize css class for each alert box */
$this->options['class'] = $this->alertTypes[$type] . $appendCss;
/* assign unique id to each alert box */
$this->options['id'] = $this->id . '-' . $type;
echo \yii\bootstrap\Alert::widget([
'body' => $message,
'closeButton' => $this->closeButton,
'options' => $this->options,
]);
}
$session->removeFlash($type);
}
}
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/user/UserOnlineTriggerWidget.php | src/widgets/user/UserOnlineTriggerWidget.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\widgets\user;
use common\models\User;
use skeeks\cms\widgets\user\assets\UserOnlineWidgetAsset;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;
use yii\helpers\Url;
/**
* Виджет отправляющий ajax запросы в бэкенд с заданной частотой
* @author Semenov Alexander <semenov@skeeks.com>
*/
class UserOnlineTriggerWidget extends Widget
{
/**
* @var array
*/
public $clientOptions = [];
/**
* @var int
*/
public $delay = 30;
public function run()
{
$this->clientOptions['id'] = $this->id;
$this->clientOptions['url'] = Url::to('/cms/online/trigger-v2');
$this->clientOptions['url_json_p'] = Url::to('/cms/online/trigger-json-p');
$delay = $this->delay * 1000;
$jsOptions = Json::encode($this->clientOptions);
$this->view->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.Online = sx.classes.Component.extend({
_onDomReady: function()
{
var self = this;
setInterval(function(){
self.request();
}, this.get('delay', {$delay}))
},
requestJsonP: function()
{
// Using YQL and JSONP
$.ajax({
url: this.get('url_json_p'),
// The name of the callback parameter, as specified by the YQL service
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Tell YQL what we want and that we want JSON
data: {
q: "select title,abstract,url from search.news where query=\"cat\"",
format: "json"
},
// Work with the response
success: function( response ) {
console.log( response ); // server response
}
});
},
request: function()
{
// Using YQL and JSONP
$.ajax({
url: this.get('url'),
// The name of the callback parameter, as specified by the YQL service
//jsonp: "callback",
// Tell jQuery we're expecting JSONP
//dataType: "jsonp",
// Tell YQL what we want and that we want JSON
/*data: {
q: "select title,abstract,url from search.news where query=\"cat\"",
format: "json"
},*/
// Work with the response
/*success: function( response ) {
console.log( response ); // server response
}*/
});
}
});
new sx.classes.Online({$jsOptions});
})(sx, sx.$, sx._);
JS
);
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/widgets/user/UserOnlineWidget.php | src/widgets/user/UserOnlineWidget.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\widgets\user;
use common\models\User;
use skeeks\cms\widgets\user\assets\UserOnlineWidgetAsset;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
/**
* Виджет отображения индикатора онлайн пользователь или офлайн
* @author Semenov Alexander <semenov@skeeks.com>
*/
class UserOnlineWidget extends Widget
{
/**
* @var User
*/
public $user = null;
/**
* @var null
*/
public $options = null;
public function run()
{
if (!$this->user) {
return '';
}
$user = $this->user;
if ($user->isOnline) {
$options = ArrayHelper::merge($this->options, [
'title' => \Yii::t('skeeks/cms', 'Online'),
'data-toggle' => 'tooltip',
]);
$online = \yii\helpers\Html::img(UserOnlineWidgetAsset::getAssetUrl('icons/round_green.gif'), $options);
} else {
$options = ArrayHelper::merge($this->options, [
'title' => \Yii::t('skeeks/cms', 'Offline'),
'data-toggle' => 'tooltip',
]);
$online = \yii\helpers\Html::img(UserOnlineWidgetAsset::getAssetUrl('icons/round_red.gif'), $options);
}
return $online;
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/user/assets/UserOnlineWidgetAsset.php | src/widgets/user/assets/UserOnlineWidgetAsset.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\widgets\user\assets;
use skeeks\cms\base\AssetBundle;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class UserOnlineWidgetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/user/assets/src';
public $css = [
];
public $js = [
];
public $depends = [
'skeeks\sx\assets\Custom',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsWorkerTasksCalendarWidget.php | src/widgets/admin/CmsWorkerTasksCalendarWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\helpers\RequestResponse;
use skeeks\cms\models\CmsTask;
use yii\base\Widget;
use yii\helpers\Html;
class CmsWorkerTasksCalendarWidget extends Widget
{
/**
* @var string
*/
public static $autoIdPrefix = 'CmsWorkerTasksCalendarWidget';
/**
* @var User
*/
public $user = null;
/**
* @var array
*/
public $options = [];
public function run()
{
$this->options['id'] = $this->id;
Html::addCssClass($this->options, "sx-worker-tasks-calendar-widget");
if (\Yii::$app->request->isPost && \Yii::$app->request->isAjax) {
if (\Yii::$app->request->post("widget") == $this->id) {
ob_get_clean();
ob_clean();
$rr = new RequestResponse();
CmsTask::recalculateTasksPriority($this->user, \Yii::$app->request->post("ids"));
/*$this->user->recalculateTasksPriority();*/
$rr->success = false;
$rr->message = "Сохранено";
\Yii::$app->response->data = $rr;
\Yii::$app->end();
}
}
$result = $this->render('worker-tasks-calendar');
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/widgets/admin/CmsUserViewWidget.php | src/widgets/admin/CmsUserViewWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsUser;
use skeeks\crm\models\CrmContractor;
use yii\base\Widget;
class CmsUserViewWidget extends Widget
{
/**
* @var CmsUser
*/
public $cmsUser = null;
/**
* @var bool Показывать только название
*/
public $isShowOnlyName = false;
/**
* @var string
*/
public $tagName = "a";
public $viewFile = "user-view";
/**
* @var string
*/
public $append = "";
/**
* @var array
*/
public $tagNameOptions = [];
/**
* @var int
*/
public $prviewImageSize = 50;
public $isSmall = false;
public function run()
{
if ($this->cmsUser) {
$cache = \Yii::$app->cache->get("cmsUser{$this->cmsUser->id}" . $this->tagName . $this->prviewImageSize);
if ($cache) {
return $cache;
}
$result = $this->render($this->viewFile);
\Yii::$app->cache->set("cmsUser{$this->cmsUser->id}", $result, 2);
return $result;
} else {
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/widgets/admin/CmsTaskStatusWidget.php | src/widgets/admin/CmsTaskStatusWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\helpers\CmsScheduleHelper;
use skeeks\cms\models\CmsTask;
use skeeks\cms\widgets\user\assets\UserOnlineWidgetAsset;
use skeeks\crm\models\CrmSchedule;
use skeeks\crm\models\CrmTask;
use yii\base\Widget;
use yii\helpers\ArrayHelper;use yii\helpers\Html;
/**
* Виджет отображения статуса задачи
*
* @author Semenov Alexander <semenov@skeeks.com>
*/
class CmsTaskStatusWidget extends Widget
{
/**
* @var CmsTask
*/
public $task = null;
/**
* @var bool
*/
public $isShort = false;
/**
* @var null
*/
public $options = null;
/**
* @return string
* @throws \yii\base\InvalidConfigException
*/
public function run()
{
if (!$this->task) {
return '';
}
$title = '';
if ($schedules = $this->task->schedules) {
$total = CmsScheduleHelper::durationAsTextBySchedules($schedules);
$title .= "<br />Отработано: {$total}<br /><br />" . CmsScheduleHelper::getAsTextBySchedules($schedules);
}
$accepted = \skeeks\cms\models\CmsTask::STATUS_ACCEPTED;
$canceled = \skeeks\cms\models\CmsTask::STATUS_CANCELED;
$work = \skeeks\cms\models\CmsTask::STATUS_IN_WORK;
$on_pause = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE;
$on_check = \skeeks\cms\models\CmsTask::STATUS_ON_CHECK;
$ready = \skeeks\cms\models\CmsTask::STATUS_READY;
$this->view->registerCss(<<<CSS
.label-status-task {
color: white;
background: #bbb;
border-radius: var(--border-radius);
}
.label-status-task:hover {
color: white;
}
.label-status-{$accepted} {
background: #9a69cb;
}
.label-status-{$canceled} {
background: var(--color-red-pale);
}
.label-status-{$work} {
background-color: #22e3be;
transition: all .2s;
animation: sx-label-pulse 1.5s infinite linear;
}
.label-status-{$on_pause} {
background-color: #e57d20;
}
.label-status-{$on_check} {
background-color: #00bed6;
}
.label-status-{$ready} {
background-color: green;
}
@keyframes sx-label-pulse {
0% {
box-shadow: 0 0 5px 0px #22e3be, 0 0 5px 0px #22e3be;
}
100% {
box-shadow: 0 0 5px 6px rgba(255, 48, 26, 0), 0 0 4px 10px rgba(255, 48, 26, 0);
}
}
CSS
);
$options = ArrayHelper::merge($this->options, [
'title' => $this->task->statusAsHint . $title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
'style' => 'cursor: unset;',
'class' => 'btn btn-xs label-status-task label-status-' . $this->task->status,
]);
$title = " " . $this->task->statusAsText;
if ($this->isShort) {
$title = "";
}
return \yii\helpers\Html::tag("span",
Html::tag('i', '', [
'class' => $this->task->statusAsIcon
]) . $title
, $options);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/TaskBtnsWidget.php | src/widgets/admin/TaskBtnsWidget.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\crm\widgets;
use common\models\User;
use skeeks\crm\models\CrmSchedule;
use skeeks\crm\models\CrmTask;
use skeeks\crm\models\CrmTaskSchedule;
use yii\base\Exception;
use yii\base\Widget;
/**
* Виджет кнопок по задаче
*
* @author Semenov Alexander <semenov@skeeks.com>
*/
class TaskBtnsWidget extends Widget
{
/**
* @var CrmTask
*/
public $task = null;
/**
* @var bool
*/
public $isPjax = true;
public function getUser()
{
return \Yii::$app->user->identity;
}
public function run()
{
$error = '';
/**
* @var $task CrmTask
*/
$task = $this->task;
$crmTaskSchedule = null;
//Если задача в работе значит есть не остановленный промежуток времени
if ($task->status == CrmTask::STATUS_IN_WORK) {
$crmTaskSchedule = $task->notEndCrmTaskSchedule;
}
if (\Yii::$app->request->post() && \Yii::$app->request->post($this->id)) {
$t = \Yii::$app->db->beginTransaction();
//die;
try {
// $task = clone $this->task;
$task = CrmTask::findOne($task->id);
//var_dump($task);die;
if ($task->load(\Yii::$app->request->post()) && $task->validate()) {
$oldAttributeStatus = $task->getOldAttribute('status');
if ($task->save()) {
if ($task->status == CrmTask::STATUS_IN_WORK) {
$crmTaskSchedule = new CrmTaskSchedule();
$crmTaskSchedule->cms_user_id = \Yii::$app->user->id;
$crmTaskSchedule->crm_task_id = $task->id;
$crmTaskSchedule->date = \Yii::$app->formatter->asDate(time(), "php:YY-m-d");
$crmTaskSchedule->start_time = \Yii::$app->formatter->asTime(time());
$crmTaskSchedule->end_time = null;
if (!$crmTaskSchedule->save()) {
$task->addError('end_time', 'Не удалось сохранить лог начала работы: ' . print_r($crmTaskSchedule->errors, true));
throw new Exception("Не удалось сохранить лог начала работы");
}
}
if (in_array($task->status, [CrmTask::STATUS_ON_PAUSE, CrmTask::STATUS_ON_CHECK]) && $oldAttributeStatus == CrmTask::STATUS_IN_WORK) {
$crmTaskSchedule->load(\Yii::$app->request->post());
if (!$crmTaskSchedule) {
$task->addError('end_time', 'Нет начального промежутка времени. Обратитесь к программисту!');
throw new Exception("Нет начального промежутка времени. Обратитесь к программисту!");
}
if (!$crmTaskSchedule->end_time) {
$crmTaskSchedule->end_time = \Yii::$app->formatter->asTime(time());
}
if (!$crmTaskSchedule->save()) {
$task->addError('end_time', 'Не удалось сохранить лог завершения работы: ' . print_r($crmTaskSchedule->errors, true));
throw new Exception("Не удалось сохранить лог завершения работы");
}
} elseif (in_array($task->status, [CrmTask::STATUS_ON_PAUSE]) && $oldAttributeStatus == CrmTask::STATUS_ON_CHECK) {
}
$this->task = $task;
} else {
throw new Exception('Не сохранился статус задачи');
}
} else {
throw new Exception('Не сохранился статус задачи');
}
$t->commit();
} catch (\Exception $e) {
$t->rollBack();
$error = $e->getMessage();
$task->addError('end_time', $e->getMessage());
//throw $e;
}
}
return $this->render('task-btns', [
'error' => $error,
'task' => $task,
'crmTaskSchedule' => $crmTaskSchedule,
]);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsWorkerViewWidget.php | src/widgets/admin/CmsWorkerViewWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsUser;
use skeeks\crm\models\CrmContractor;
use yii\base\Widget;
class CmsWorkerViewWidget extends Widget
{
/**
* @var CmsUser
*/
public $user = null;
/**
* @var bool Показывать только название
*/
public $isShowOnlyName = false;
/**
* @var string
*/
public $tagName = "a";
public $viewFile = "worker-view";
/**
* @var string
*/
public $append = "";
/**
* @var array
*/
public $tagNameOptions = [];
/**
* @var int
*/
public $prviewImageSize = 50;
public $isSmall = false;
public function run()
{
if ($this->user) {
$cache = \Yii::$app->cache->get("cmsUser{$this->user->id}" . $this->tagName . $this->prviewImageSize . $this->isSmall);
if ($cache) {
return $cache;
}
$result = $this->render($this->viewFile);
\Yii::$app->cache->set("cmsUser{$this->user->id}", $result, 2);
return $result;
} else {
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/widgets/admin/CmsUserScheduleBtnWidget.php | src/widgets/admin/CmsUserScheduleBtnWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsUser;
use skeeks\cms\models\CmsUserSchedule;
use skeeks\crm\models\CrmContractor;
use yii\base\Exception;
use yii\base\Widget;
class CmsUserScheduleBtnWidget extends Widget
{
public function getUser()
{
return \Yii::$app->user->identity;
}
public function run()
{
$error = '';
$CmsUserSchedule = CmsUserSchedule::find()->user($this->user)->notEnd()->one();
if (\Yii::$app->request->post() && \Yii::$app->request->post('action-type')) {
//die;
try {
if (\Yii::$app->request->post('action-type') == 'start') {
if ($CmsUserSchedule) {
throw new Exception("Для начала нужно завершить работу.");
}
$CmsUserSchedule = new CmsUserSchedule();
$CmsUserSchedule->cms_user_id = $this->user->id;
$CmsUserSchedule->start_at = time();
$CmsUserSchedule->end_at = null;
if (!$CmsUserSchedule->save()) {
//throw new Exception(print_r($CmsUserSchedule->errors, true));
}
$this->user->refresh();
}
if (\Yii::$app->request->post('action-type') == 'stop') {
if (!$CmsUserSchedule) {
throw new Exception("Вы не в работе");
}
$CmsUserSchedule = CmsUserSchedule::find()->user($this->user)->notEnd()->one();
$CmsUserSchedule->load(\Yii::$app->request->post());
//TODO: Поправить проверка на день
if (!$CmsUserSchedule->end_at) {
$CmsUserSchedule->end_at = time();
}
if (!$CmsUserSchedule->save()) {
//throw new Exception(print_r($CmsUserSchedule->errors, true));
}
$this->user->refresh();
}
} catch (\Exception $e) {
$error = $e->getMessage();
}
}
return $this->render('schedule-btn', [
'error' => $error,
'cmsUserSchedule' => $CmsUserSchedule ? $CmsUserSchedule : new CmsUserSchedule(),
]);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsCommentWidget.php | src/widgets/admin/CmsCommentWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsUser;
use skeeks\crm\models\CrmContractor;
use yii\base\Widget;
class CmsCommentWidget extends Widget
{
/**
* @var null
*/
public $model = null;
/**
* @var bool Перезагружать контейнер pjax если это возможно, если его нет, то перезагрузить страницу после написания комментария
*/
public $isPjax = true;
public $backend_url = ['/cms/admin-cms-log/add-comment'];
public function run()
{
return $this->render('comment');
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsWebNotifyWidget.php | src/widgets/admin/CmsWebNotifyWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsUser;
use skeeks\cms\models\CmsUserSchedule;
use skeeks\crm\models\CrmContractor;
use yii\base\Exception;
use yii\base\Widget;
class CmsWebNotifyWidget extends Widget
{
public function getUser()
{
return \Yii::$app->user->identity;
}
public function run()
{
$error = '';
$CmsUserSchedule = CmsUserSchedule::find()->user($this->user)->notEnd()->one();
if (\Yii::$app->request->post() && \Yii::$app->request->post('action-type')) {
//die;
try {
if (\Yii::$app->request->post('action-type') == 'start') {
if ($CmsUserSchedule) {
throw new Exception("Для начала нужно завершить работу.");
}
$CmsUserSchedule = new CmsUserSchedule();
$CmsUserSchedule->cms_user_id = $this->user->id;
$CmsUserSchedule->start_at = time();
$CmsUserSchedule->end_at = null;
if (!$CmsUserSchedule->save()) {
//throw new Exception(print_r($CmsUserSchedule->errors, true));
}
$this->user->refresh();
}
if (\Yii::$app->request->post('action-type') == 'stop') {
if (!$CmsUserSchedule) {
throw new Exception("Вы не в работе");
}
$CmsUserSchedule = CmsUserSchedule::find()->user($this->user)->notEnd()->one();
$CmsUserSchedule->load(\Yii::$app->request->post());
//TODO: Поправить проверка на день
if (!$CmsUserSchedule->end_at) {
$CmsUserSchedule->end_at = time();
}
if (!$CmsUserSchedule->save()) {
//throw new Exception(print_r($CmsUserSchedule->errors, true));
}
$this->user->refresh();
}
} catch (\Exception $e) {
$error = $e->getMessage();
}
}
return $this->render('web-notify');
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsProjectViewWidget.php | src/widgets/admin/CmsProjectViewWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsProject;
use skeeks\crm\models\CrmProject;
use yii\base\Widget;
class CmsProjectViewWidget extends Widget
{
/**
* @var CmsProject
*/
public $project = null;
/**
* @var bool Показывать только название
*/
public $isShowOnlyName = false;
/**
* @var string
*/
public $tagName = "a";
/**
* @var array
*/
public $tagNameOptions = [];
/**
* @var int
*/
public $prviewImageSize = 40;
public function run()
{
return $this->render('project-view');
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsTaskBtnsWidget.php | src/widgets/admin/CmsTaskBtnsWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsTask;
use skeeks\cms\models\CmsTaskSchedule;
use skeeks\crm\models\CrmSchedule;
use yii\base\Exception;
use yii\base\Widget;
/**
* Виджет кнопок по задаче
*
* @author Semenov Alexander <semenov@skeeks.com>
*/
class CmsTaskBtnsWidget extends Widget
{
/**
* @var CmsTask
*/
public $task = null;
/**
* @var bool
*/
public $isPjax = true;
public function getUser()
{
return \Yii::$app->user->identity;
}
public function run()
{
$error = '';
/**
* @var $task CmsTask
*/
$task = $this->task;
$CmsTaskSchedule = null;
//Если задача в работе значит есть не остановленный промежуток времени
if ($task->status == CmsTask::STATUS_IN_WORK) {
$CmsTaskSchedule = CmsTaskSchedule::find()->task($task)->notEnd()->one();
/*$CmsTaskSchedule = $task->notEndCmsTaskSchedule;*/
}
$isSaved = false;
if (\Yii::$app->request->post() && \Yii::$app->request->post($this->id)) {
$t = \Yii::$app->db->beginTransaction();
//die;
try {
// $task = clone $this->task;
$task = CmsTask::findOne($task->id);
//var_dump($task);die;
if ($task->load(\Yii::$app->request->post()) && $task->validate()) {
$oldAttributeStatus = $task->getOldAttribute('status');
if ($task->save()) {
if ($task->status == CmsTask::STATUS_IN_WORK) {
$CmsTaskSchedule = new CmsTaskSchedule();
$CmsTaskSchedule->cms_user_id = \Yii::$app->user->id;
$CmsTaskSchedule->cms_task_id = $task->id;
$CmsTaskSchedule->start_at = time();
$CmsTaskSchedule->end_at = null;
if (!$CmsTaskSchedule->save()) {
$task->addError('end_at', 'Не удалось сохранить лог начала работы: ' . print_r($CmsTaskSchedule->errors, true));
throw new Exception("Не удалось сохранить лог начала работы");
}
}
if (in_array($task->status, [CmsTask::STATUS_ON_PAUSE, CmsTask::STATUS_ON_CHECK, CmsTask::STATUS_READY]) && $oldAttributeStatus == CmsTask::STATUS_IN_WORK) {
$CmsTaskSchedule->load(\Yii::$app->request->post());
if (!$CmsTaskSchedule) {
$task->addError('end_at', 'Нет начального промежутка времени. Обратитесь к программисту!');
throw new Exception("Нет начального промежутка времени. Обратитесь к программисту!");
}
if (!$CmsTaskSchedule->end_at) {
$CmsTaskSchedule->end_at = time();
}
if (!$CmsTaskSchedule->save()) {
$task->addError('end_at', 'Не удалось сохранить лог завершения работы: ' . print_r($CmsTaskSchedule->errors, true));
throw new Exception("Не удалось сохранить лог завершения работы");
}
} elseif (in_array($task->status, [CmsTask::STATUS_ON_PAUSE]) && $oldAttributeStatus == CmsTask::STATUS_ON_CHECK) {
}
$this->task = $task;
} else {
throw new Exception('Не сохранился статус задачи');
}
} else {
throw new Exception('Не сохранился статус задачи');
}
$t->commit();
$isSaved = true;
} catch (\Exception $e) {
$t->rollBack();
$error = $e->getMessage();
$task->addError('end_at', $e->getMessage());
//throw $e;
}
}
return $this->render('task-btns', [
'error' => $error,
'task' => $task,
'isSaved' => $isSaved,
'CmsTaskSchedule' => $CmsTaskSchedule,
]);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsLogListWidget.php | src/widgets/admin/CmsLogListWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsUser;
use skeeks\crm\models\CrmContractor;
use yii\base\Widget;
class CmsLogListWidget extends Widget
{
public $query = null;
public $is_show_model = true;
public $list_view_config = [];
public function run()
{
return $this->render('log-list');
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/CmsTaskViewWidget.php | src/widgets/admin/CmsTaskViewWidget.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\widgets\admin;
use common\models\User;
use skeeks\cms\models\CmsTask;
use skeeks\crm\models\CrmProject;
use skeeks\crm\models\CrmTask;
use yii\base\Widget;
class CmsTaskViewWidget extends Widget
{
/**
* @var CmsTask
*/
public $task = null;
/**
* @var bool Показывать только название
*/
public $isShowOnlyName = false;
/**
* @var string
*/
public $tagName = "a";
/**
* @var array
*/
public $tagNameOptions = [];
/**
* @var int
*/
public $prviewImageSize = 40;
public $isShowStatus = false;
public $isStatusShort = true;
/**
* @var bool
*/
public $isAction = true;
static protected $_isRegisterAssets = false;
public function run()
{
if (self::$_isRegisterAssets === false) {
self::$_isRegisterAssets = true;
$this->view->registerCss(<<<CSS
.sx-task-info .img-wrapper {
margin-right: 0.75rem;
}
.sx-task-wrapper .sx-task-status {
margin: auto;
margin-left: 0.5rem;
}
.sx-task-info {
display: flex;
align-items: center;
}
.sx-task-wrapper {
display: flex;
}
CSS
);
}
return $this->render('task-view');
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/task-btns.php | src/widgets/admin/views/task-btns.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 \common\models\User */
/* @var $error string */
/* @var $widget \skeeks\crm\widgets\TaskBtnsWidget */
/* @var $crmTaskSchedule \skeeks\cms\models\CmsTaskSchedule */
$widget = $this->context;
$user = $widget->user;
$accepted = \skeeks\cms\models\CmsTask::STATUS_ACCEPTED;
$canceled = \skeeks\cms\models\CmsTask::STATUS_CANCELED;
$work = \skeeks\cms\models\CmsTask::STATUS_IN_WORK;
$on_check = \skeeks\cms\models\CmsTask::STATUS_ON_CHECK;
$on_pause = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE;
$on_ready = \skeeks\cms\models\CmsTask::STATUS_READY;
$this->registerCss(<<<CSS
.btn-task {
color: white;
border-radius: var(--border-radius);
margin-right: 0.25rem;
}
.btn-task:hover {
color: white;
}
.btn-task-{$accepted} {
background: #9a69cb;
}
.btn-task-{$canceled} {
background: var(--color-gray);
}
.btn-task-{$work} {
background-color: #22e3be;
}
.btn-task-{$on_check} {
background-color: #00bed6;
}
.btn-task-{$on_pause} {
background-color: #e57d20;
}
.btn-task-{$on_ready} {
background-color: green;
}
CSS
);
?>
<? if ($widget->isPjax) : ?>
<? $pjax = \skeeks\cms\widgets\Pjax::begin([
'id' => 'sx-pjax-'.$widget->id,
'enablePushState' => false,
'isBlock' => false,
'timeout' => 10000,
'options' => [
'class' => 'g-color-gray-dark-v6',
],
]); ?>
<? endif; ?>
<div class="sx-task-btns">
<?
if ($isSaved) {
$this->registerJs(<<<JS
sx.Window.openerWidgetTriggerEvent('model-create', {
'submitBtn' : 'apply'
});
JS
);
}
$form = \yii\widgets\ActiveForm::begin([
'id' => "form-".$widget->id,
'options' => [
'data-pjax' => 1,
],
]);
$title = '';
?>
<div style="display: none;">
<input type="hidden" name="<?= $widget->id; ?>" value="1"/>
<?= $form->field($widget->task, "status")->textInput(['class' => 'sx-task-status']); ?>
</div>
<? if ($widget->task->executor_id == \Yii::$app->user->id) : ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_NEW) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_ACCEPTED; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_ACCEPTED).'"></i> Взять задачу',
[
'class' => 'btn btn-task btn-task-' . \skeeks\cms\models\CmsTask::STATUS_ACCEPTED,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ACCEPTED).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_ACCEPTED) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_IN_WORK; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_IN_WORK).'"></i> Начать работу',
[
'class' => 'btn btn-task btn-task-' . \skeeks\cms\models\CmsTask::STATUS_IN_WORK,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_IN_WORK).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_IN_WORK) : ?>
<?/* if ($widget->task->notEndCrmTaskSchedule && $widget->task->notEndCrmTaskSchedule->date != date("Y-m-d")) : */?><!--
<div class="row">
<div class="col-md-12" style="color: red;">
Когда была завершена задача <?/*= \Yii::$app->formatter->asDate($widget->task->notEndCrmTaskSchedule->date); */?>?
</div>
<div class="col-md-3">
<?/*= $form->field($crmTaskSchedule, 'end_time')->textInput([
'placeholder' => '11:30'
])->label(false); */?>
</div>
<div class="col-md-3">
<?/* $status = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE; */?>
<?/*= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).'"></i> На паузу',
[
'class' => 'btn btn-task '.\yii\helpers\ArrayHelper::getValue(\skeeks\cms\models\CmsTask::statusesColors(),
\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE),
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); */?>
</div>
</div>
--><?/* else : */?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).'"></i> На паузу',
[
'class' => 'btn btn-task btn-task-'.\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<?php if($task->executor_id == $task->created_by) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_READY; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_READY).'"></i> Готова',
[
'class' => 'btn btn-task btn-task-'. \skeeks\cms\models\CmsTask::STATUS_READY,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_READY).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<?php else : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_ON_CHECK; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_ON_CHECK).'"></i> На проверку',
[
'class' => 'btn btn-task btn-task-'.\skeeks\cms\models\CmsTask::STATUS_ON_CHECK,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ON_CHECK).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<?php endif; ?>
<?/* endif; */?>
<? endif; ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_IN_WORK; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_IN_WORK).'"></i> Начать работу',
[
'class' => 'btn btn-task btn-task-'.\skeeks\cms\models\CmsTask::STATUS_IN_WORK,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_IN_WORK).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? endif; ?>
<? if ($widget->task->created_by == \Yii::$app->user->id || $widget->task->executor_id == \Yii::$app->user->id) : ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_NEW || $widget->task->status == \skeeks\cms\models\CmsTask::STATUS_ACCEPTED) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_CANCELED; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_CANCELED).'"></i> Отменить',
[
'class' => 'btn btn-task btn-task-'.\skeeks\cms\models\CmsTask::STATUS_CANCELED,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_CANCELED).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_CANCELED) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE; ?>
<?= \yii\helpers\Html::button('<i class="fas fa-redo"></i> Возобновить',
[
'class' => 'btn btn-task btn-task-' . \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? endif; ?>
<? if ($widget->task->created_by == \Yii::$app->user->id) : ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_ON_CHECK) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE; ?>
<?= \yii\helpers\Html::button('<i class="fas fa-redo"></i> Возобновить',
[
'class' => 'btn btn-task btn-task-' . \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_READY; ?>
<?= \yii\helpers\Html::button('<i class="'.\skeeks\cms\models\CmsTask::statusesIcons(\skeeks\cms\models\CmsTask::STATUS_READY).'"></i> Готова',
[
'class' => 'btn btn-task btn-task-'. \skeeks\cms\models\CmsTask::STATUS_READY,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_READY).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? if ($widget->task->status == \skeeks\cms\models\CmsTask::STATUS_READY) : ?>
<? $status = \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE; ?>
<?= \yii\helpers\Html::button('<i class="fas fa-redo"></i> Возобновить',
[
'class' => 'btn btn-task btn-task-' . \skeeks\cms\models\CmsTask::STATUS_ON_PAUSE,
'type' => 'submit',
'onclick' => "$(this).tooltip('hide'); $('.sx-task-status', '#form-{$widget->id}').val('{$status}');",
'title' => \skeeks\cms\models\CmsTask::statusesFeatureHints(\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE).$title,
'data-toggle' => 'tooltip',
'data-html' => 'true',
]); ?>
<? endif; ?>
<? endif; ?>
<?= $form->errorSummary($task, ['header' => '']); ?>
<? $form::end(); ?>
<!--</form>-->
</div>
<? if ($widget->isPjax) : ?>
<? $pjax::end(); ?>
<? endif; ?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/user-view.php | src/widgets/admin/views/user-view.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 $cmsUser \skeeks\cms\models\CmsUser
*/
$widget = $this->context;
$cmsUser = $widget->cmsUser;
$class = 'g-brd-gray-light-v4';
?>
<div class="d-flex flex-row sx-preview-card">
<div>
<?php
$w = \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([
'controllerId' => '/cms/admin-user',
'modelId' => $cmsUser->id,
'content' => $cmsUser->shortDisplayNameWithAlias,
'isRunFirstActionOnClick' => true,
'options' => [
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-pjax' => '0',
'style' => 'border: 0;',
],
]); ?>
<? if ($cmsUser->image) : ?>
<img src="<?= \Yii::$app->imaging->thumbnailUrlOnRequest($cmsUser->image ? $cmsUser->image->src : \skeeks\cms\helpers\Image::getCapSrc(),
new \skeeks\cms\components\imaging\filters\Thumbnail([
'h' => $widget->prviewImageSize,
'w' => $widget->prviewImageSize,
'm' => \Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND,
])); ?>" alt=""
class="sx-photo <?= $class; ?> sx-img-size-<?= $widget->isSmall ? "small" : $widget->prviewImageSize; ?>"
data-toggle="tooltip"
data-html="true"
>
<? else : ?>
<div class="sx-no-photo g-brd-gray-light-v4 sx-img-size-<?= $widget->isSmall ? "small" : $widget->prviewImageSize; ?>">
<?= \skeeks\cms\helpers\StringHelper::strtoupper(
\skeeks\cms\helpers\StringHelper::substr($cmsUser->shortDisplayNameWithAlias, 0, 2)
); ?>
</div>
<? endif; ?>
<?php $w::end(); ?>
</div>
<div>
<?php
$options = \yii\helpers\ArrayHelper::merge([
'style' => 'text-align: left; white-space: nowrap;',
'class' => '',
'href' => '#',
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-pjax' => '0',
], (array) $widget->tagNameOptions);
echo \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::widget([
'controllerId' => '/cms/admin-user',
'modelId' => $cmsUser->id,
'isRunFirstActionOnClick' => true,
'content' => $cmsUser->shortDisplayNameWithAlias,
'tag' => $widget->tagName,
'options' => $options,
]); ?>
<? if ($widget->isShowOnlyName === false) : ?>
<? if ($cmsUser->phone) : ?>
<div class="sx-phone">
<a href="tel:<?= $cmsUser->phone; ?>" style="color: gray; font-size: 12px; text-decoration: none; border-bottom: 0px;">
<i class="fas fa-phone"></i> <?= $cmsUser->phone; ?>
</a>
</div>
<? endif; ?>
<? if ($cmsUser->email) : ?>
<div class="sx-mail">
<a href="mailto:<?= $cmsUser->email; ?>" style="color: gray; font-size: 12px; text-decoration: none; border-bottom: 0px;">
<i class="far fa-envelope"></i> <?= $cmsUser->email; ?>
</a>
</div>
<? endif; ?>
<? endif; ?>
<? if ($widget->append) : ?>
<?php echo $widget->append; ?>
<? endif; ?>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/task-view.php | src/widgets/admin/views/task-view.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 $task \skeeks\cms\models\CmsTask */
/* @var $project \skeeks\cms\models\CmsProject */
/* @var $widget \skeeks\cms\widgets\admin\CmsTaskViewWidget */
$widget = $this->context;
$task = $widget->task;
$class = 'g-brd-gray-light-v4';
$title = "";
$cmsImage = null;
$project = $task->cmsProject;
$company = $task->cmsCompany;
$client = $task->cmsUser;
$titleData = [];
$letter = $task->name;
if ($project && $project->cmsImage) {
$cmsImage = $project->cmsImage;
} elseif ($company && $company->cmsImage) {
$cmsImage = $company->cmsImage;
}
if ($project) {
$titleData[] = "Проект: ".$project->name;
$letter = $project->name;
}
if ($company) {
$titleData[] = "Компания: ".$company->name;
$letter = $company->name;
}
if ($client) {
$titleData[] = "Клиент: ".$client->name;
$letter = $client->name;
}
$actionData = \yii\helpers\Json::encode([
"isOpenNewWindow" => true,
"url" => (string)\skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(["/cms/admin-cms-task/view", "pk" => $task->id])->enableEmptyLayout()->enableNoActions()->url,
]);
?>
<div class="sx-task-wrapper sx-preview-card">
<div class="sx-task-info">
<div class="img-wrapper">
<? if ($cmsImage) : ?>
<? if ($widget->isAction) : ?>
<a href="<?= \yii\helpers\Url::to(["/cms/admin-cms-task/view", "pk" => $task->id]); ?>" data-pjax="0" style="border: 0;"
title="<?= implode("; ", $titleData); ?>" data-toggle="tooltip"
onclick='<?= new \yii\web\JsExpression(<<<JS
new sx.classes.backend.widgets.Action({$actionData}).go(); return false;
JS
); ?>'
>
<? endif; ?>
<img src="<?= \Yii::$app->imaging->thumbnailUrlOnRequest($cmsImage ? $cmsImage->src : \skeeks\cms\helpers\Image::getCapSrc(),
new \skeeks\cms\components\imaging\filters\Thumbnail([
'h' => $widget->prviewImageSize,
'w' => $widget->prviewImageSize,
'm' => \Imagine\Image\ManipulatorInterface::THUMBNAIL_OUTBOUND,
])); ?>" alt=""
class="sx-photo <?= $class; ?> sx-img-size-<?= $widget->prviewImageSize; ?>"
title="<?= $title; ?>"
data-toggle="tooltip"
data-html="true"
>
<? if ($widget->isAction) : ?>
</a>
<? endif; ?>
<? else : ?>
<div class="sx-no-photo g-brd-gray-light-v4 sx-img-size-<?= $widget->prviewImageSize; ?>">
<? if ($widget->isAction) : ?>
<a href="<?= \yii\helpers\Url::to(["/cms/admin-cms-task/view", "pk" => $task->id]); ?>" data-pjax="0" style="border: 0;"
title="<?= implode("; ", $titleData); ?>" data-toggle="tooltip"
onclick="<?= new \yii\web\JsExpression(<<<JS
new sx.classes.backend.widgets.Action({$actionData}).go(); return false;
JS
); ?>"
>
<? endif; ?>
<?= \skeeks\cms\helpers\StringHelper::strtoupper(
\skeeks\cms\helpers\StringHelper::substr($letter, 0, 2)
); ?>
<? if ($widget->isAction) : ?>
</a>
<? endif; ?>
</div>
<? endif; ?>
</div>
<div>
<? if ($widget->isAction) : ?>
<?= \yii\helpers\Html::tag($widget->tagName, $task->asText, \yii\helpers\ArrayHelper::merge([
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-pjax' => '0',
'class' => 'sx-main-info',
'title' => $task->asText,
'href' => \yii\helpers\Url::to(["/cms/admin-cms-task/view", "pk" => $task->id]),
"onclick" => new \yii\web\JsExpression(<<<JS
new sx.classes.backend.widgets.Action({$actionData}).go(); return false;
JS
),
], $widget->tagNameOptions)); ?>
<? else: ?>
<?= \yii\helpers\Html::tag($widget->tagName, $task->asText, \yii\helpers\ArrayHelper::merge([
'href' => "#",
'class' => "sx-main-info",
], $widget->tagNameOptions)); ?>
<? endif; ?>
<? if ($widget->isShowOnlyName === false) : ?>
<br/>
<? $worked = \skeeks\cms\helpers\CmsScheduleHelper::durationBySchedules($task->schedules); ?>
<div class="sx-employee" style="font-size: 12px; <?= $worked > $task->plan_duration ? "color: var(--color-red-pale);" : "color: var(--color-gray);"; ?>">
<!--<span title="Создана: <? /*= \Yii::$app->formatter->asDatetime($task->created_at); */ ?>" data-toggle="tooltip"><? /*= \Yii::$app->formatter->asRelativeTime($task->created_at); */ ?></span>-->
<? if ($worked) : ?>
<span title="Отработано" data-toggle="tooltip">
<?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsText($worked); ?>
</span> /
<? else : ?>
<? endif; ?>
<span title="Запланированное время" data-toggle="tooltip">
<?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsText($task->plan_duration); ?>
</span>
<?= $worked > $task->plan_duration ? "переработка!" : ""; ?>
<? if ($task->plan_start_at) : ?>
/ <span title="Запланирована на это время" data-toggle="tooltip"><?php echo \Yii::$app->formatter->asDatetime($task->plan_start_at); ?></span>
<? if ($task->plan_start_at < time()) : ?>
/ <span style="color: var(--color-red-pale);">Просрочена!</span>
<? endif; ?>
<? endif; ?>
</div>
<? endif; ?>
</div>
</div>
<?php if($widget->isShowStatus) : ?>
<div class="sx-task-status">
<?php echo \skeeks\cms\widgets\admin\CmsTaskStatusWidget::widget([
'task' => $widget->task,
'isShort' => $widget->isStatusShort,
]); ?>
</div>
<?php endif; ?>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/schedule-btn.php | src/widgets/admin/views/schedule-btn.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 \common\models\User */
/* @var $error string */
/* @var $widget \common\modules\work\widgets\ScheduleBtnWidget */
$widget = $this->context;
$user = $widget->user;
?>
<? $this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.InfoSchedule = sx.classes.Component.extend({
_init: function()
{
var self = this;
setInterval(function()
{
self.update();
}, 30000);
},
update: function()
{
$.pjax.reload("#" + this.get('id'), {async:false});
},
});
new sx.classes.InfoSchedule({
'id': 'sx-schedule-pjax'
});
})(sx, sx.$, sx._);
JS
);
$this->registerCss(<<<CSS
#sx-schedule-pjax {
display: flex;
}
#sx-schedule-pjax>div {
margin-left: 1rem;
}
#sx-schedule-pjax .sx-current-task .sx-preview-card img.sx-photo {
width: 2rem;
height: 2rem;
}
#sx-schedule-pjax .sx-current-task .sx-main-info {
overflow: hidden;
max-height: 40px;
}
#sx-schedule-pjax .sx-current-task {
line-height: 1;
max-width: 30rem;
max-height: 40px;
margin-left: 2rem;
}
#sx-schedule-pjax .sx-current-task .sx-preview-card img.sx-photo {
width: 2rem;
height: 2rem;
}
.sx-schedule-last {
animation: sx-pulse 3s infinite ease;
}
@keyframes sx-pulse {
0%{
opacity: 1;
background: rgba(255, 48, 26, 0);
box-shadow: none;
}
54%{
background: rgba(255, 48, 26, 0);
box-shadow: none;
opacity: 0;
}
55%{
opacity: 0;
/*box-shadow: 0 0 9px 1px red, 0 0 10px 0px red;*/
/*background: #5c5c5c;*/
}
100%{
opacity: 1;
/*box-shadow: 0 0 13px -9px red, 0 0 32px 20px red;*/
/*background: rgba(255, 48, 26, 0);*/
}
}
CSS
);
?>
<? $pjax = \skeeks\cms\widgets\Pjax::begin([
'id' => 'sx-schedule-pjax',
'enablePushState' => false,
'isBlock' => false,
'timeout' => 100000,
'options' => [
'class' => '',
],
]); ?>
<? $form = \yii\widgets\ActiveForm::begin([
'options' => [
'data-pjax' => 1,
'class' => "my-auto",
],
]); ?>
<?php
$notEndCrmSchedule = \skeeks\cms\models\CmsUserSchedule::find()->user($user)->notEnd()->one();
?>
<? if ($notEndCrmSchedule) : ?>
<? /* if ($user->notEndCrmSchedule->date == date("Y-m-d")) : */ ?>
<? if (1 == 1) : ?>
<input type="hidden" value="stop" name="action-type"/>
<?
$time = $notEndCrmSchedule->durationAsText;
?>
<?= \yii\helpers\Html::button('<i class="fa fa-stop" style="color: white;"></i> '.\Yii::$app->formatter->asTime($notEndCrmSchedule->start_at,
"short")." — <span class='sx-schedule-last'>".\Yii::$app->formatter->asTime(time(),
"short")."</span>",
[
'class' => 'btn btn-md btn-primary',
'type' => 'submit',
'onclick' => "$(this).tooltip('hide')",
'title' => 'Остановить работу. <br />В промежутке: '.$time,
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-placement' => 'right',
]); ?>
<? else : ?>
<div style="color: red;">
Когда вы закончили работу?<br/>
<?= \Yii::$app->formatter->asDate($user->notEndCrmSchedule->date); ?>
</div>
<input type="hidden" value="stop" name="action-type"/>
<div class="row">
<div class="col-md-6">
<?= $form->field($cmsUserSchedule, 'start_time')->textInput([
'placeholder' => "11:30",
'disabled' => "disabled",
])->label(false); ?>
</div>
<div class="col-md-6">
<?= $form->field($cmsUserSchedule, 'end_time')->textInput(['placeholder' => "11:30"])->label(false); ?>
</div>
</div>
<?
$time = $user->notEndCrmSchedule->durationAsText;
?>
<?= \yii\helpers\Html::button('<i class="fa fa-stop"></i> '.\Yii::$app->formatter->asTime($user->notEndCrmSchedule->start_time, "short")." — <span style='color: silver;'>?</span>",
[
'class' => 'btn btn-md u-btn-inset u-btn-inset--rounded u-btn-primary g-font-weight-600 g-letter-spacing-0_5 g-brd-2 g-rounded-50 g-mr-10',
'type' => 'submit',
'onclick' => "$(this).tooltip('hide')",
'title' => 'Остановить работу. <br />В промежутке: '.$time,
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-placement' => 'right',
]); ?>
<? endif; ?>
<? else : ?>
<input type="hidden" value="start" name="action-type"/>
<?= \yii\helpers\Html::button('<i class="fa fa-play" style="color: white;"></i> Начать работу', [
'class' => 'btn btn-md btn-primary',
'type' => 'submit',
'onclick' => "$(this).tooltip('hide')",
'title' => 'Включить учет времени',
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-placement' => 'right',
]); ?>
<? endif; ?>
<? /* print_r($cmsSchedule->errors); */ ?>
<?= $form->errorSummary($cmsUserSchedule, ['header' => false]); ?>
<? $form::end(); ?>
<!--</form>-->
<?
$cmsSchedulesByDate = \skeeks\cms\models\CmsUserSchedule::find()->user($user)->today()->all();
if ($cmsSchedulesByDate) : ?>
<div class="my-auto">
<a href="#" style="cursor: unset;" data-toggle="tooltip" data-html="true"
title="Сегодня: <?php echo \skeeks\cms\helpers\CmsScheduleHelper::durationAsTextBySchedules($cmsSchedulesByDate)."<br>".\skeeks\cms\helpers\CmsScheduleHelper::getAsTextBySchedules($cmsSchedulesByDate); ?>">
<i class="fas fa-info"></i>
</a>
</div>
<!--<div class="my-auto">
<a href="#" >
Сегодня: <? /*= \skeeks\crm\helpers\CrmScheduleHelper::durationAsTextBySchedules($cmsSchedulesByDate); */ ?>
</a>
</div>-->
<? endif; ?>
<? if ($error) : ?>
<div class="col-md-12">
<p style="color: red;"><?= $error; ?></p>
</div>
<? endif; ?>
<?php if($notEndCrmSchedule): ?>
<div class="my-auto sx-current-task">
<?php if ($currentTask = \skeeks\cms\models\CmsTask::find()->executor(\Yii::$app->user->identity)->statusInWork()->one()) : ?>
<?php echo \skeeks\cms\widgets\admin\CmsTaskViewWidget::widget([
'task' => $currentTask,
'isShowOnlyName' => true,
'isShowStatus' => true,
]);
?>
<?php else : ?>
<a href="<?php echo \yii\helpers\Url::to(['/cms/admin-cms-task/index']); ?>" data-pjax="0" data-toggle="tooltip" title="У вас не запущена никакая задача, возьмите задачу в работу в этом разделе.">Выбрать задачу!</a>
<?php endif; ?>
</div>
<?php else : ?>
<div class="my-auto sx-current-task">
<a href="<?php echo \yii\helpers\Url::to(['/cms/admin-cms-task/index']); ?>" data-pjax="0" data-toggle="tooltip" title="У вас не запущена работа. Нажмите на кнопку и начните работу. Система будет вести учет вашего рабочего времени.">Включите таймер!</a>
</div>
<?php endif; ?>
<? $pjax::end(); ?>
<? $this->registerJs(<<<JS
$("body").on('click', ".sx-total-link", function() {
$('.sx-schedule-times').toggle();
$(this).tooltip('hide');
return false;
});
JS
); ?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/comment.php | src/widgets/admin/views/comment.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 $widget \skeeks\cms\widgets\admin\CmsCommentWidget
*/
$widget = $this->context;
?>
<?php
$log = new \skeeks\cms\models\CmsLog();
$log->model_code = $widget->model->skeeksModelCode;
$log->model_id = $widget->model->id;
$isPjax = (int) $widget->isPjax;
$form = \skeeks\cms\base\widgets\ActiveFormAjaxSubmit::begin([
'action' => \yii\helpers\Url::to($widget->backend_url),
'enableAjaxValidation' => false,
'enableClientValidation' => false,
'clientCallback' => new \yii\web\JsExpression(<<<JS
function (ActiveFormAjaxSubmit) {
ActiveFormAjaxSubmit.on('success', function(e, response) {
var isPjax = {$isPjax};
ActiveFormAjaxSubmit.AjaxQueryHandler.set("allowResponseSuccessMessage", false);
ActiveFormAjaxSubmit.AjaxQueryHandler.set("allowResponseErrorMessage", false);
$(".sx-success-result", ActiveFormAjaxSubmit.jForm).empty().append("<div class='sx-message'>✓ " + response.message + "</div>");
var jPjax = ActiveFormAjaxSubmit.jForm.closest("[data-pjax-container]");
if (jPjax.length) {
console.log(jPjax);
setTimeout(function() {
$.pjax.reload({ container: "#" + jPjax.attr("id"), async:false });
}, 1000);
} else {
setTimeout(function() {
window.location.reload();
}, 1000);
}
});
ActiveFormAjaxSubmit.on('error', function(e, response) {
ActiveFormAjaxSubmit.AjaxQueryHandler.set("allowResponseSuccessMessage", false);
ActiveFormAjaxSubmit.AjaxQueryHandler.set("allowResponseErrorMessage", false);
$(".error-summary ul", ActiveFormAjaxSubmit.jForm).empty().append("<li>" + response.message + "</li>");
$(".error-summary", ActiveFormAjaxSubmit.jForm).show();
});
}
JS
),
]); ?>
<div class="row">
<div class="col-12">
<?php
$this->registerCss(<<<CSS
.cke_bottom {
background: none !important;
border-top: none !important;
}
.cke_path {
display: none !important;
}
.cke_chrome {
box-shadow: none !important;
border: 1px solid #C2C2C2 !important;
border-radius: 0.5rem !important;
}
.cke_top {
background: none !important;
border-bottom: 1px solid #C2C2C2 !important;
border-radius: 0.5rem !important;
}
.cke_inner {
border-radius: 0.5rem !important;
}
.cke_toolgroup {
background: none !important;
border: none !important;
}
CSS
);
echo $form->field($log, "comment")->widget(
\skeeks\yii2\ckeditor\CKEditorWidget::class,
[
'preset' => false,
'clientOptions' => [
'enterMode' => 2,
'placeholder' => 'test',
'editorplaceholder' => 'test',
/*'editorplaceholder' => 'test',*/
/*'placeholder' => 'test',
'editorplaceholder' => 'test',*/
'height' => 120,
'allowedContent' => false,
//'extraPlugins' => 'ckwebspeech,lineutils,dialogui',
'toolbar' => [
[
'name' => 'basicstyles',
'groups' => ['basicstyles', 'cleanup'],
'items' => ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
],
[
'name' => 'paragraph',
'groups' => ['list', 'indent', 'blocks', 'align', 'bidi'],
'items' => [
'NumberedList',
'BulletedList',
'-',
'Blockquote',
'-',
'JustifyLeft',
'JustifyCenter',
'JustifyRight',
'JustifyBlock',
],
],
/*[
'name' => 'paragraph',
'groups' => ['list', 'indent', 'blocks', 'align', 'bidi'],
'items' => [
'NumberedList',
'BulletedList',
'-',
'Blockquote',
'-',
'JustifyLeft',
'JustifyCenter',
'JustifyRight',
'JustifyBlock',
],
],*/
['name' => 'links', 'items' => ['Link','Unlink']],
],
],
])->label(false); ?>
</div>
<div class="col-12">
<div style="display: none;">
<?php echo $form->field($log, "model_code"); ?>
<?php echo $form->field($log, "model_id"); ?>
</div>
<?php echo $form->field($log, "fileIds")->widget(\skeeks\cms\widgets\AjaxFileUploadWidget::class, [
//'accept' => 'image/*',
'multiple' => true,
/*'is_show_file_info' => false,
'is_allow_deselect' => false,
'tools' => [
'remote' => new \yii\helpers\UnsetArrayValue(),
],*/
])->label(false); ?>
</div>
<div class="col-12">
<div class="d-flex">
<button type="submit" class="btn btn-primary" style="margin-right: 1rem;">Отправить</button>
<div class="sx-success-result my-auto" style="flex-grow: 1; color: green;"></div>
</div>
</div>
</div>
<?php echo $form->errorSummary([$log], ['header' => false]); ?>
<?php $form::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/widgets/admin/views/web-notify.php | src/widgets/admin/views/web-notify.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 \common\models\User */
/* @var $error string */
/* @var $widget \common\modules\work\widgets\ScheduleBtnWidget */
$widget = $this->context;
$user = $widget->user;
\skeeks\cms\backend\widgets\assets\ControllerActionsWidgetAsset::register($this);
\skeeks\cms\backend\widgets\AjaxControllerActionsWidget::registerAssets();
?>
<?
/**
* @var \skeeks\cms\models\CmsWebNotify[] $qNotifiesNotPopups
*/
/*$qNotifiesNotPopups = \Yii::$app->user->identity->getCmsWebNotifies()->notPopup()->limit(3)->all();
$qNotifiesNotPopupsArray = [];
if ($qNotifiesNotPopups) {
foreach ($qNotifiesNotPopups as $qNotifiesNotPopup)
{
$qNotifiesNotPopupsArray[] = \yii\helpers\ArrayHelper::merge(['render' => $qNotifiesNotPopup->getHtml()], $qNotifiesNotPopup->toArray());
}
}*/
$qNotifies = \Yii::$app->user->identity->getCmsWebNotifies()->notRead();
$notReaded = $qNotifies->count();
$lastNotify = $qNotifies->limit(1)->one();
$jsData = [
'backend_notifies' => \yii\helpers\Url::to(['/cms/ajax/web-notifies']),
'backend_notifies_new' => \yii\helpers\Url::to(['/cms/ajax/web-notifies-new']),
'backend_notifies_clear' => \yii\helpers\Url::to(['/cms/ajax/web-notifies-clear']),
'id' => "sx-notifies-wrapper",
'sound_src' => \skeeks\cms\assets\CmsAsset::getAssetUrl("sound/sound_telegram.mp3"),
'last_notify_id' => $lastNotify ? $lastNotify->id : ''
];
$js = \yii\helpers\Json::encode($jsData);
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.WebNotify = sx.classes.Component.extend({
_init: function()
{
var self = this;
self.jBage = $(".sx-bage-notifies", self.getJWrapper());
self.jTrigger = $(".sx-trigger-notifies", self.getJWrapper());
self.jContainer = $(".sx-notifies", self.getJWrapper());
self.jEmptyContainer = $(".sx-empty", self.getJWrapper());
self.jItemsContainer = $(".sx-notifies-has-items", self.getJWrapper());
self.jList = $(".sx-notifies-list", self.getJWrapper());
self.jBtnClear = $(".sx-btn-clear", self.getJWrapper());
self.jTrigger.on("click", function() {
self.jContainer.fadeIn();
self.loadMessages();
});
self.jBtnClear.on("click", function() {
self.jContainer.fadeOut();
self.clearMessages();
});
$(document).mouseup(function (e) {
var isClose = true;
if ($(e.target).closest(".sx-notifies-wrapper").length != 0){
isClose = false;
}
if (isClose) {
self.jContainer.fadeOut();
}
});
setInterval(function()
{
self.checkNewNotifies();
}, 10000);
},
checkNewNotifies: function() {
var self = this;
var ajaxQuery = sx.ajax.preparePostQuery(self.get("backend_notifies_new"), {
'last_notify_id' : self.get('last_notify_id')
});
var ajaxHandler = new sx.classes.AjaxHandlerStandartRespose(ajaxQuery, {
'blockerSelector' : self.jContainer,
'enableBlocker': false,
'allowResponseSuccessMessage': false,
'allowResponseErrorMessage': false,
'ajaxExecuteErrorAllowMessage': false,
});
ajaxHandler.on('error', function (e, response) {
/*console.log(response.data);*/
});
ajaxHandler.on('success', function (e, response) {
if (response.data.items.length) {
response.data.items.forEach(function(item) {
/*sx.notify.info(item.render, { life: 1000000 });*/
sx.notify.info(item.render);
self.set("last_notify_id", item.id);
var audio = new Audio();
audio.src = self.get("sound_src");
audio.play();
});
}
if (response.data.total > 0) {
self.jBage.empty().append(response.data.total);
self.getJWrapper().addClass("sx-has-notifies");
} else {
self.jBage.empty();
self.getJWrapper().removeClass("sx-has-notifies");
}
});
ajaxQuery.execute();
},
loadMessages: function() {
var self = this;
var ajaxQuery = sx.ajax.preparePostQuery(self.get("backend_notifies"));
var ajaxHandler = new sx.classes.AjaxHandlerStandartRespose(ajaxQuery, {
'blockerSelector' : self.jContainer,
'enableBlocker': true,
'allowResponseSuccessMessage': false,
'allowResponseErrorMessage': false,
'ajaxExecuteErrorAllowMessage': false,
});
ajaxHandler.on('error', function (e, response) {
/*console.log(response.data);*/
});
ajaxHandler.on('success', function (e, response) {
if (response.data.items.length) {
self.jEmptyContainer.hide();
self.jItemsContainer.show();
self.jList.empty();
response.data.items.forEach(function(item) {
self.jList.append(item.render);
});
} else {
self.jEmptyContainer.show();
self.jList.hide();
}
if (response.data.total > 0) {
self.jBage.empty().append(response.data.total);
self.getJWrapper().addClass("sx-has-notifies");
} else {
self.jBage.empty();
self.getJWrapper().removeClass("sx-has-notifies");
}
});
ajaxQuery.execute();
},
clearMessages: function() {
var self = this;
var ajaxQuery = sx.ajax.preparePostQuery(self.get("backend_notifies_clear"));
var ajaxHandler = new sx.classes.AjaxHandlerStandartRespose(ajaxQuery, {
'blockerSelector' : self.jContainer,
'enableBlocker': true,
'allowResponseSuccessMessage': false,
'allowResponseErrorMessage': false,
'ajaxExecuteErrorAllowMessage': false,
});
ajaxHandler.on('error', function (e, response) {
/*console.log(response.data);*/
});
ajaxHandler.on('success', function (e, response) {
self.jItemsContainer.hide();
self.jEmptyContainer.show();
self.jList.hide();
});
ajaxQuery.execute();
},
getJWrapper: function() {
return $("#" + this.get("id"));
}
});
new sx.classes.WebNotify({$js});
})(sx, sx.$, sx._);
JS
);
$this->registerCss(<<<CSS
.sx-notifies .sx-notifies-btns {
display: flex;
justify-content: right;
margin-top: 1rem;
}
.sx-notifies .sx-model .sx-action-trigger {
cursor: pointer;
border-bottom: 1px solid;
}
.sx-notifies .sx-notifies-list .sx-item .sx-time {
color: #8294b9;
}
.sx-notifies .sx-notifies-list .sx-item.sx-not-read {
margin-left: 1rem;
}
.sx-notifies .sx-notifies-list .sx-item.sx-not-read:before {
content: "•";
position: absolute;
left: -1rem;
top: 50%;
transform: translateY(-50%);
color: var(--color-red-pale);
}
.sx-notifies .sx-notifies-list .sx-item {
margin-bottom: 1rem;
position: relative;
}
.sx-notifies .sx-notifies-list .sx-item:last-child {
margin-bottom: 0;
}
.sx-notifies {
background: #1d1d1d !important;
/*background: white !important;*/
width: 25rem;
display: none;
position: absolute;
top: 4rem;
right: -2rem;
min-height: 4rem;
border-radius: var(--border-radius);
padding: 0.5rem;
box-shadow: 0 7px 21px rgba(83, 92, 105, .12), 0 -1px 6px 0 rgba(83, 92, 105, .06);
}
.sx-notifies-wrapper .sx-notifies-has-items,
.sx-notifies-wrapper .sx-empty {
display: none;
}
.sx-notifies-wrapper .sx-empty {
text-align: center;
}
.sx-notifies-wrapper .dropdown-toggle::after {
content: none;
}
.sx-notifies-wrapper .sx-notifies-list {
max-height: 70vh;
overflow-y: auto;
}
.sx-notifies-wrapper .sx-notifies-list,
.sx-notifies-wrapper .sx-empty {
padding: 1rem;
}
.sx-notifies-wrapper .sx-bage-notifies {
display: none;
transition: all .2s;
animation: sx-pulse-bage 1.5s infinite linear;
}
.sx-notifies-wrapper.sx-has-notifies .sx-bage-notifies {
display: block;
}
@keyframes sx-pulse-bage {
0% {
box-shadow: 0 0 5px 0px var(--color-red), 0 0 5px 0px var(--color-red);
}
100% {
box-shadow: 0 0 5px 6px rgba(255, 48, 26, 0), 0 0 4px 10px rgba(255, 48, 26, 0);
}
}
CSS
);
?>
<div class="sx-btn-backend-header sx-notifies-wrapper <?php echo $notReaded ? "sx-has-notifies" : ""; ?>" id="sx-notifies-wrapper">
<a class="d-block sx-trigger-notifies" href="#">
<span class="sx-badge sx-bage-notifies"><?php echo $notReaded; ?></span>
<i class="hs-admin-bell g-absolute-centered"></i>
</a>
<div class="sx-notifies">
<div class="sx-notifies-has-items">
<div class="sx-notifies-list">
</div>
<div class="sx-notifies-btns">
<button class="btn btn-primary btn-xs sx-btn-clear">Очистить</button>
</div>
</div>
<div class="sx-empty">Все уведомления прочитаны</div>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/worker-tasks-calendar.php | src/widgets/admin/views/worker-tasks-calendar.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 \common\models\User */
/* @var $widget \skeeks\crm\widgets\WorkerTasksCalendarWidget */
$widget = $this->context;
$user = $widget->user;
$model = $user;
?>
<?= \yii\helpers\Html::beginTag("div", $widget->options); ?>
<div class="row">
<div class="col-sm-12">
<!--<h5 class="g-mt-14">Календарь задач</h5>-->
<div class="row g-mb-20" style="margin-bottom: 1rem;">
<div class="col-sm-12">
<div class="pull-left">
<button class="btn btn-primary sx-save-priority-btn"><i class="fa fa-save"></i> Сохранить порядок задач</button>
</div>
<div class="pull-right">
<?
$btnCreateTask = '';
if ($controller = \Yii::$app->createController('/cms/admin-cms-task')) {
$controller = $controller[0];
if ($createAction = \yii\helpers\ArrayHelper::getValue($controller->actions, 'create')) {
/**
* @var $createAction BackendModelCreateAction
*/
$r = new \ReflectionClass(\skeeks\cms\models\CmsTask::class);
$createAction->url = \yii\helpers\ArrayHelper::merge($createAction->urlData, [
$r->getShortName() => [
'executor_id' => $user->id,
],
]);
$createAction->name = "Добавить задачу";
$btnCreateTask = \skeeks\cms\backend\widgets\ControllerActionsWidget::widget([
'actions' => [$createAction],
'isOpenNewWindow' => true,
'minViewCount' => 1,
'itemTag' => 'button',
'itemOptions' => ['class' => 'btn btn-primary'],
/*'button' => [
'class' => 'btn btn-primary',
//'style' => 'font-size: 11px; cursor: pointer;',
'tag' => 'a',
'label' => 'Зарегистрировать номер',
],*/
]);
}
}
?>
<?= $btnCreateTask; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<?
\yii\jui\Sortable::widget();
?>
<?
$json = \yii\helpers\Json::encode([
'url' => \Yii::$app->request->url,
'id' => $widget->id,
]);
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.WorkCalendar = sx.classes.Component.extend({
_onDomReady: function()
{
var self = this;
$(".sx-save-priority-btn").on('click', function() {
if ($(this).is('disabled')) {
return false;
}
var newSort = [];
$(".sx-task-tr").each(function(i, element)
{
newSort.push($(this).data("id"));
});
var blocker = sx.block("#" + self.get('id'));
var id = self.get('id');
var ajax = sx.ajax.preparePostQuery(
self.get('url'),
{
"ids" : newSort,
'widget' : id
}
);
//new sx.classes.AjaxHandlerStandartRespose(ajax); //отключение глобального загрузчика
new sx.classes.AjaxHandlerNotify(ajax, {
'error': "Изменения не сохранились",
'success': "Изменения сохранены",
}); //отключение глобального загрузчика
ajax
/*.onError(function(e, data)
{
sx.notify.error("Подождите сейчас страница будет перезагружена");
_.delay(function()
{
window.location.reload();
}, 2000);
})*/
.onSuccess(function(e, data)
{
blocker.unblock();
_.delay(function()
{
window.location.reload();
}, 200);
})
.execute();
});
$(".sx-calendar-day tbody").sortable({
connectWith: ".sx-calendar-day tbody",
cursor: "n-resize",
dropOnEmpty: false,
handle: ".sx-move-btn",
forceHelperSize: true,
forcePlaceholderSize: true,
opacity: 0.5,
placeholder: "ui-state-highlight",
out: function( event, ui )
{
$(".sx-save-priority-btn").fadeIn();
}
});
//$( ".sx-calendar-day tbody" ).sortable( "option", "handle", "button" );
}
});
new sx.classes.WorkCalendar({$json});
})(sx, sx.$, sx._);
JS
);
?>
<?
$this->registerCss(<<<CSS
@keyframes sx-save-priority-pulse {
0% {
box-shadow: 0 0 5px 0px var(--primary-color), 0 0 5px 0px var(--primary-color);
}
100% {
box-shadow: 0 0 5px 6px rgba(255, 48, 26, 0), 0 0 4px 10px rgba(255, 48, 26, 0);
}
}
.sx-save-priority-btn {
position: fixed;
display: none;
left: 50%;
top: 50%;
z-index: 99;
animation: sx-save-priority-pulse 1.5s infinite linear;
}
.sx-task-hidden .sx-task-td {
position: relative;
}
.sx-task-hidden .sx-task-td:after {
position: absolute;
content: "Не доступна";
top: 0;
left: 0;
width: 100%;
height: 100%;
/* filter: blur(1.5rem); */
background: white;
display: flex;
justify-content: left;
align-items: center;
color: silver;
}
.table.sx-calendar-day thead th {
border-bottom: 0;
}
.sx-calendar-day th {
background: var(--primary-color) !important;
color: white;
border: none;
}
.sx-calendar-day{
border: 1px solid var(--primary-color);
background: white;
overflow: hidden;
border-radius: var(--border-radius);
border: 0;
}
.sx-not-work-day {
border-radius: var(--border-radius);
}
.sx-not-work-day th {
background: var(--color-gray) !important;
}
.sx-not-today-day {
opacity: 0.9;
}
.sx-not-today-day:hover {
opacity: 1;
}
CSS
);
$scheduleTotalTime = \skeeks\cms\models\CmsTaskSchedule::find()->select([
'SUM((end_at - start_at)) as total_timestamp',
])->where([
'cms_task_id' => new \yii\db\Expression(\skeeks\cms\models\CmsTask::tableName() . ".id"),
]);
$tasks = \skeeks\cms\models\CmsTask::find()->select([
\skeeks\cms\models\CmsTask::tableName().'.*',
'executorPriority' => new \yii\db\Expression("IF(executor_sort is not null, executor_sort, 9999999)"),
'scheduleTotalTime' => $scheduleTotalTime,
'planTotalTime' => new \yii\db\Expression(\skeeks\cms\models\CmsTask::tableName().".plan_duration"),
])->where([
'executor_id' => $model->id,
])->andWhere([
'status' => [
\skeeks\cms\models\CmsTask::STATUS_NEW,
\skeeks\cms\models\CmsTask::STATUS_IN_WORK,
\skeeks\cms\models\CmsTask::STATUS_ON_PAUSE,
\skeeks\cms\models\CmsTask::STATUS_ACCEPTED,
],
])->orderBy([
'executorPriority' => SORT_ASC,
'id' => SORT_DESC,
])
->all();
$elseDayTime = 0;
$workShedule = $user->work_shedule;
?>
<? for ($i = 0; $i <= 1000; $i++) : ?>
<?
$workShedule = $user->work_shedule;
//День в цикле
$date = date("Y-m-d", strtotime("+{$i} day"));
$times = \skeeks\cms\helpers\CmsScheduleHelper::getSchedulesByWorktimeForDate($workShedule, $date);
$timesForCalculate = $times;
$seconds = \skeeks\cms\helpers\CmsScheduleHelper::durationBySchedules($times);
$timesToday = [];
$isToday = false;
if ($date == \Yii::$app->formatter->asDate(time(), "php:Y-m-d")) {
$timesToday = \skeeks\cms\helpers\CmsScheduleHelper::getFilteredSchedulesByStartTime($times);
/*print_r($times);
print_r($timesToday);*/
$timesForCalculate = $timesToday;
$isToday = true;
$workedSeconds = \skeeks\cms\helpers\CmsScheduleHelper::durationBySchedules($times);
}
?>
<table class="table sx-table sx-calendar-day <?= !$times ? "sx-not-work-day" : ""; ?> <?= $date != \Yii::$app->formatter->asDate(time(), "php:Y-m-d") ? "sx-not-today-day" : ""; ?>">
<thead>
<tr>
<th class="text-center" colspan="4"><?= \Yii::$app->formatter->asDate($date, 'full'); ?>
<? if ($times) : ?>
<a href="<?= \yii\helpers\Url::to(['/cms/admin-user/planschedule', 'pk' => $model->id]); ?>" target="_blank" style="color: white;">
<small data-toggle="tooltip" title="Время по графику: <br /><br /><?= \skeeks\cms\helpers\CmsScheduleHelper::getAsTextBySchedules($times); ?>" data-html="true">
(всего по графику: <?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsText($seconds); ?>)
</small>
</a>
<? if ($timesToday) : ?>
<small data-toggle="tooltip" title="Осталось сегодня исходя из графика: <br /><br /><?= \skeeks\cms\helpers\CmsScheduleHelper::getAsTextBySchedules($timesToday); ?>" data-html="true">
(еще отработает: <?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsTextBySchedules($timesToday); ?>)
</small>
<? elseif (!$timesToday && $date == \Yii::$app->formatter->asDate(time(), "php:Y-m-d")) : ?>
<? if ($workedSeconds > $seconds) : ?>
<small data-toggle="tooltip" title="Сегодня отработал сверх плана: <br /><br /><?= \skeeks\cms\helpers\CmsScheduleHelper::getAsTextBySchedules($user->crmSchedulesByDate); ?>" data-html="true">
(отработал сверх плана: <?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsText($workedSeconds - $seconds); ?>)
</small>
<? else: ?>
<small data-toggle="tooltip" title="Не доработано: <br /><br /><?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsText($seconds - $workedSeconds); ?>" data-html="true">
(Не доработано: <?= \skeeks\cms\helpers\CmsScheduleHelper::durationAsText($seconds - $workedSeconds); ?>)
</small>
<? endif; ?>
<? endif; ?>
<? else : ?>
<a href="<?= \yii\helpers\Url::to(['/crm/crm-user/planschedule', 'pk' => $model->id]); ?>" target="_blank" style="color: white;">
<small>(Не работает)</small>
</a>
<? endif; ?>
</th>
</tr>
<? if ($isToday) : ?>
<?/*
$subquery = \skeeks\crm\models\CrmTaskSchedule::find()
->orderBy([
\skeeks\crm\models\CrmTaskSchedule::tableName().".date" => SORT_DESC,
\skeeks\crm\models\CrmTaskSchedule::tableName().".end_time" => SORT_DESC
])
;
$qt = \skeeks\crm\models\CrmTask::find()->where(['executor_id' => $model->id])
->leftJoin(['crmTaskSchedules' => $subquery], ['crmTaskSchedules.crm_task_id' => new \yii\db\Expression(\skeeks\crm\models\CrmTask::tableName().".id")])
->andWhere([
'status' => [
\skeeks\crm\models\CrmTask::STATUS_ON_CHECK,
\skeeks\crm\models\CrmTask::STATUS_READY,
\skeeks\crm\models\CrmTask::STATUS_CANCELED,
],
])
->andWhere(["crmTaskSchedules.date" => $date])
->groupBy([
\skeeks\crm\models\CrmTask::tableName().".id"
])
->orderBy([
'crmTaskSchedules.end_time' => SORT_ASC
])
;
*/?>
<?
//Только промежутки закрытые в этот день
$subquery = \skeeks\cms\models\CmsTaskSchedule::find()
->select([
\skeeks\cms\models\CmsTaskSchedule::tableName() . ".*",
"date_formated_end" => new \yii\db\Expression("DATE_FORMAT(FROM_UNIXTIME(" . \skeeks\cms\models\CmsTaskSchedule::tableName() . ".end_at), '%Y-%m-%d')")
])
->orderBy([
"date_formated_end" => SORT_DESC,
\skeeks\cms\models\CmsTaskSchedule::tableName().".end_at" => SORT_DESC
])
->andHaving(["date_formated_end" => $date])
;
$qt = \skeeks\cms\models\CmsTask::find()
->select([
\skeeks\cms\models\CmsTask::tableName() . ".*",
"schedules_end_at" => "schedules.end_at",
])
->where(['executor_id' => $model->id])
->innerJoin(['schedules' => $subquery], ['schedules.cms_task_id' => new \yii\db\Expression(\skeeks\cms\models\CmsTask::tableName().".id")])
->andWhere([
'status' => [
\skeeks\cms\models\CmsTask::STATUS_ON_CHECK,
\skeeks\cms\models\CmsTask::STATUS_READY,
\skeeks\cms\models\CmsTask::STATUS_CANCELED,
],
])
->groupBy([
\skeeks\cms\models\CmsTask::tableName().".id"
])
->orderBy([
'schedules_end_at' => SORT_ASC
])
;
/*$qt = \skeeks\cms\models\CmsTask::find()
->select([
\skeeks\cms\models\CmsTask::tableName() . ".*",
"schedules_end_at" => "schedules.end_at",
"date_formated_end" => new \yii\db\Expression("DATE_FORMAT(FROM_UNIXTIME(schedules.end_at), '%Y-%m-%d')")
])
->joinWith("schedules as schedules")
->andWhere(['executor_id' => $model->id])
->andHaving(['date_formated_end' => $date])
->andWhere([
'status' => [
\skeeks\cms\models\CmsTask::STATUS_ON_CHECK,
\skeeks\cms\models\CmsTask::STATUS_READY,
\skeeks\cms\models\CmsTask::STATUS_CANCELED,
],
])
->groupBy([
\skeeks\cms\models\CmsTask::tableName().".id"
])
->orderBy([
'schedules_end_at' => SORT_ASC
])
;*/
/*print_R($qt->createCommand()->rawSql);*/
?>
<? if ($tasksToday = $qt->all()) : ?>
<? foreach ($tasksToday as $t) : ?>
<?
$isCan = true;
if (\Yii::$app->user->id != $user->id) {
$isCan = \Yii::$app->user->can("cms/admin-task/manage", ['model' => $t]);
}
?>
<?= \yii\helpers\Html::beginTag('tr', [
'class' => 'sx-task-tr ' . ($isCan ? "" : "sx-task-hidden"),
'style' => ' opacity: 0.5;
background: #e5fde5;'
]); ?>
<td style="width: 45px;">
</td>
<td style="width: 45px;">
</td>
<td class="sx-task-td">
<?= \skeeks\cms\widgets\admin\CmsTaskViewWidget::widget(['task' => $t]); ?>
<?/*= \skeeks\crm\widgets\TaskViewWidget::widget(['task' => $t]); */?>
</td>
<td style="width: 50px;">
<?= \skeeks\cms\widgets\admin\CmsTaskStatusWidget::widget(['task' => $t, 'isShort' => true]); ?>
<?/*= \skeeks\crm\widgets\TaskStatusWidget::widget(['task' => $t, 'isShort' => true]); */?>
</td>
<?= \yii\helpers\Html::endTag('tr'); ?>
<? endforeach; ?>
<? endif; ?>
<? endif; ?>
</thead>
<? if ($times) : ?>
<tbody>
<?
$dayTime = \skeeks\cms\helpers\CmsScheduleHelper::durationBySchedules($timesForCalculate);
/*echo $dayTime;*/
$dayTime = $dayTime + $elseDayTime;
/*echo "/" . $dayTime;*/
?>
<? if ($tasks) : ?>
<? foreach ($tasks as $key => $task) : ?>
<?
$isCan = true;
if (\Yii::$app->user->id != $user->id) {
$isCan = \Yii::$app->user->can("cms/admin-task/manage", ['model' => $task]);
}
$time = $task->raw_row['planTotalTime'] - $task->raw_row['scheduleTotalTime'];
if ($time < 0) {
$time = 0;
}
$dayTime = $dayTime - $time;
$tr = [
'class' => 'sx-task-tr ' . ($isCan ? "" : "sx-task-hidden"),
'data' => [
'id' => $task->id,
'executor_sort' => $task->executor_sort,
],
];
if ($task->status == \skeeks\crm\models\CrmTask::STATUS_IN_WORK) {
$tr['class'] = "sx-task-tr g-bg-in-work";
}
?>
<?= \yii\helpers\Html::beginTag('tr', $tr); ?>
<td style="width: 45px;">
<span title="Перетащите для изменеия порядка" style="line-height: 35px;">
<a href="#" class="btn u-btn-white sx-move-btn" style="color: gray; cursor: n-resize;">
<i class="fas fa-arrows-alt-v"></i>
</a>
</span>
</td>
<td style="width: 45px;">
<span title="Сотировка задачи" data-toggle="tooltip" style="line-height: 35px;">
<?= $task->executor_sort; ?>
</span>
</td>
<td class="sx-task-td">
<?= \skeeks\cms\widgets\admin\CmsTaskViewWidget::widget(['task' => $task]); ?>
<?/*= \skeeks\crm\widgets\TaskViewWidget::widget(['task' => $task]); */?>
</td>
<td style="width: 50px;">
<?/*= \skeeks\crm\widgets\TaskStatusWidget::widget(['task' => $task, 'isShort' => true]); */?>
<?= \skeeks\cms\widgets\admin\CmsTaskStatusWidget::widget(['task' => $task, 'isShort' => true]); ?>
</td>
<?= \yii\helpers\Html::endTag('tr'); ?>
<?
unset($tasks[$key]);
if ($dayTime <= 0) {
$elseDayTime = $dayTime;
break;
}
?>
<? endforeach; ?>
<? else : ?>
</tbody>
</table>
<? break; ?>
<? endif; ?>
</tbody>
<? else : ?>
<thead>
<tr>
<td class="text-center" colspan="4" style="color: gray;">
Не делает задачи в этот день
</td>
</tr>
</thead>
<? endif; ?>
</table>
<? endfor; ?>
</div>
</div>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/_log-list-item.php | src/widgets/admin/views/_log-list-item.php | <?php
/**
* @var $this yii\web\View
* @var $model \skeeks\cms\models\CmsLog
*/
$log = $model;
?>
<div class="sx-block sx-item">
<div class="sx-controlls d-flex" style="margin-bottom: 0.25rem;">
<div class="d-flex" style="flex-grow: 1;">
<div style="margin-right: 1rem; color: #a1a1a1; font-size: 0.8rem;" class="my-auto"><?php echo \Yii::$app->formatter->asDatetime($log->created_at); ?></div>
<div style="margin-right: 1rem; font-size: 0.8rem; color: #a1a1a1;" class="my-auto">
<?php echo $log->logTypeAsText; ?>
</div>
</div>
<div style="margin-right: 1rem; font-size: 0.8rem; color: #a1a1a1;" class="my-auto">
<?php
if ($log->createdBy) {
$u = $log->createdBy;
$u->post = null;
echo \skeeks\cms\widgets\admin\CmsWorkerViewWidget::widget([
'user' => $u,
'isSmall' => true,
]);
}
?>
</div>
</div>
<div class="sx-headers"></div>
<div class="">
<?php if ($log->model && $log->model->id != $model->id) : ?>
<div class="d-flex sx-model" style="flex-grow: 1;">
<?php $widget = \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([
'controllerId' => \yii\helpers\ArrayHelper::getValue(\Yii::$app->skeeks->modelsConfig, [$log->model_code, 'controller']),
'modelId' => $log->model->id,
'isRunFirstActionOnClick' => true,
'options' => [
'class' => 'sx-dashed',
'style' => 'cursor: pointer; border-bottom: 1px dashed; color: #a1a1a1;',
],
]); ?>
<?php echo $log->model->asText; ?>
<?php $widget::end(); ?>
</div>
<?php endif; ?>
<?php if ($log->subModel) : ?>
<div class="d-flex" style="flex-grow: 1;">
<?php $widget = \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([
'controllerId' => \yii\helpers\ArrayHelper::getValue(\Yii::$app->skeeks->modelsConfig, [$log->sub_model_code, 'controller']),
'modelId' => $log->subModel->id,
'isRunFirstActionOnClick' => true,
'options' => [
'class' => 'sx-dashed',
'style' => 'cursor: pointer; border-bottom: 1px dashed; color: #a1a1a1;',
],
]); ?>
<?php echo $log->subModel->asText; ?>
<?php $widget::end(); ?>
</div>
<?php endif; ?>
<?php /*echo $log->comment; */ ?>
<?php /*echo $model->renderLog($log); */ ?>
<div class="sx-comment-wrapper">
<?php echo $model->render(); ?>
</div>
<?php if ($model->files) : ?>
<?
$files = $model->files;
$images = [];
foreach ($files as $key => $file) {
if ($file->isImage()) {
$images[] = $file;
unset($files[$key]);
}
}
?>
<div class="sx-files">
<?php if ($images) : ?>
<div class="sx-title">Приложенные изображения:</div>
<div class="sx-files-block">
<? foreach ($images as $key => $file) : ?>
<a href="<?php echo $file->src; ?>" target="_blank" data-pjax="0">
<img src="<?php echo $file->src; ?>"/>
</a>
<? endforeach; ?>
</div>
<?php endif; ?>
<?php if ($files) : ?>
<div class="sx-title">Приложенные файлы:</div>
<div class="sx-files-block">
<? foreach ($files as $key => $file) : ?>
<div class="sx-file-item">
<a href="<?php echo $file->src; ?>" target="_blank" data-pjax="0"><?php echo $file->original_name; ?></a>
<a href="<?php echo \yii\helpers\Url::to(['/cms/admin-storage-files/download', 'pk' => $file->id]); ?>" target="_blank" data-pjax="0" class="btn btn-xs btn-default">скачать (<?php echo \Yii::$app->formatter->asShortSize($file->size); ?>)</a>
</div>
<? endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="sx-right-btn">
<?
\skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([
'controllerId' => "/cms/admin-cms-log",
'modelId' => $model->id,
'tag' => 'div',
'options' => [
'title' => 'Редактировать',
'class' => 'sx-edit-btn btn btn-default',
],
]);
?>
<!--<i class="hs-admin-angle-down"></i>-->
<i class="fas fa-ellipsis-v"></i>
<?php \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::end(); ?>
</div>
</div> | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/worker-view.php | src/widgets/admin/views/worker-view.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 $cmsUser \skeeks\cms\models\CmsUser
*/
$widget = $this->context;
$cmsUser = $widget->user;
$class = 'g-brd-gray-light-v4';
?>
<div class="d-flex flex-row sx-preview-card">
<div class="my-auto">
<?php
$w = \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([
'controllerId' => '/cms/admin-worker',
'modelId' => $cmsUser->id,
'content' => $cmsUser->shortDisplayNameWithAlias,
'isRunFirstActionOnClick' => true,
'options' => [
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-pjax' => '0',
'style' => 'border: 0;',
],
]); ?>
<? if ($cmsUser->image) : ?>
<img src="<?= \Yii::$app->imaging->thumbnailUrlOnRequest($cmsUser->image ? $cmsUser->image->src : \skeeks\cms\helpers\Image::getCapSrc(),
new \skeeks\cms\components\imaging\filters\Thumbnail([
'h' => $widget->prviewImageSize,
'w' => $widget->prviewImageSize,
'm' => \Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND,
])); ?>" alt=""
class="sx-photo <?= $class; ?> sx-img-size-<?= $widget->isSmall ? "small" : $widget->prviewImageSize; ?>"
data-toggle="tooltip"
data-html="true"
>
<? else : ?>
<div class="sx-no-photo g-brd-gray-light-v4 sx-img-size-<?= $widget->isSmall ? "small" : $widget->prviewImageSize; ?>">
<?= \skeeks\cms\helpers\StringHelper::strtoupper(
\skeeks\cms\helpers\StringHelper::substr($cmsUser->shortDisplayNameWithAlias, 0, 2)
); ?>
</div>
<? endif; ?>
<?php $w::end(); ?>
</div>
<div class="my-auto">
<?php
$options = \yii\helpers\ArrayHelper::merge([
'style' => 'text-align: left; white-space: nowrap;',
'class' => '',
'href' => '#',
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-pjax' => '0',
], (array)$widget->tagNameOptions);
?>
<? $ajaxWidget = \skeeks\cms\backend\widgets\AjaxControllerActionsWidget::begin([
'controllerId' => '/cms/admin-worker',
'modelId' => $cmsUser->id,
'isRunFirstActionOnClick' => true,
'tag' => $widget->tagName,
'options' => $options,
]); ?>
<?php echo $cmsUser->shortDisplayNameWithAlias; ?>
<?php echo \skeeks\cms\widgets\user\UserOnlineWidget::widget([
'user' => $cmsUser,
'options' => [
'height' => '8px;',
//'style' => 'margin-bottom: 2px;',
],
]); ?>
<?php $ajaxWidget::end(); ?>
<?php if ($widget->isSmall === false) : ?>
<?php if ($cmsUser->post) : ?>
<div style="color: gray; font-size: 12px; text-decoration: none; border-bottom: 0px;"><?php echo $cmsUser->post; ?></div>
<?php endif; ?>
<? if ($widget->append) : ?>
<?php echo $widget->append; ?>
<? endif; ?>
<? endif; ?>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/admin/views/log-list.php | src/widgets/admin/views/log-list.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 $widget \skeeks\cms\widgets\admin\CmsLogListWidget
*/
$widget = $this->context;
if (!$widget->is_show_model) {
$this->registerCss(<<<CSS
.sx-log-list .sx-model {
display: none !important;
}
CSS
);
}
$this->registerCss(<<<CSS
.sx-list .sx-files img {
border-radius: var(--border-radius);
max-width: 10rem;
border: 1px solid var(--color-light-gray);
}
.sx-list .sx-controlls a {
color: #a1a1a1;
}
.sx-log-list .sx-hidden-content .sx-hidden {
display: none;
}
.sx-log-list .sx-right-btn {
position: absolute;
right: 1rem;
bottom: 1rem;
}
.sx-log-list .sx-edit-btn {
color: silver;
cursor: pointer;
opacity: 0;
margin-right: 5px;
transition: 0.4s;
}
.sx-log-list .sx-item {
position: relative;
}
.sx-log-list .sx-item .sx-files .sx-file-item {
margin-bottom: 0.25rem;
}
.sx-log-list .sx-item .sx-files .sx-files-block {
background: var(--bg-color-light);
padding: 1rem;
border-radius: var(--border-radius);
}
.sx-log-list .sx-item .sx-files .sx-title {
color: var(--color-gray);
font-size: 0.85rem;
margin-bottom: 0.5rem;
margin-top: 1rem;
}
.sx-log-list .sx-item:hover .sx-edit-btn {
opacity: 1;
}
CSS
);
\skeeks\cms\assets\LinkActvationAsset::register($this);
$this->registerJs(<<<JS
new sx.classes.LinkActivation('.sx-comment-wrapper');
JS
);
$dataProvider = new \yii\data\ActiveDataProvider([
'query' => $widget->query,
'sort' => [
'defaultOrder' => [
'created_at' => SORT_DESC,
],
],
'pagination' => [
'defaultPageSize' => 50,
],
]);
?>
<? echo \yii\widgets\ListView::widget(\yii\helpers\ArrayHelper::merge([
'dataProvider' => $dataProvider,
'itemView' => '_log-list-item',
'emptyText' => '<div class="sx-block">Записей нет</div>',
'options' => [
'class' => '',
'tag' => 'div',
],
'itemOptions' => [
'tag' => 'div',
'class' => 'sx-item-wrapper col-12',
],
'pager' => [
'container' => '.sx-list',
'item' => '.sx-item-wrapper',
'class' => \skeeks\cms\themes\unify\widgets\ScrollAndSpPager::class,
],
//'summary' => "Всего товаров: {totalCount}",
'summary' => false,
//"\n{items}<div class=\"box-paging\">{pager}</div>{summary}<div class='sx-js-pagination'></div>",
'layout' => '<div class="row"><div class="col-md-12 sx-list-summary">{summary}</div></div>
<div class="no-gutters row sx-list sx-log-list">{items}</div>
<div class="row"><div class="col-md-12">{pager}</div></div>',
], (array) $widget->list_view_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/widgets/admin/views/project-view.php | src/widgets/admin/views/project-view.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 $project \skeeks\crm\models\CrmProject */
/* @var $widget \skeeks\crm\widgets\ProjectViewWidget */
$widget = $this->context;
$project = $widget->project;
$class = 'g-brd-gray-light-v4';
$title = $project->is_private ? "Проект закрытый" : "Проект открытый";
$actionData = \yii\helpers\Json::encode([
"isOpenNewWindow" => true,
"url" => (string)\skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(["/cms/admin-cms-project/view", "pk" => $project->id])->enableEmptyLayout()->enableNoActions()->url,
]);
?>
<div class="g-font-weight-300 g-color-gray-dark-v6 align-items-center sx-preview-card">
<div class="" style="float: left; margin-right: 10px;">
<? if ($project->cmsImage) : ?>
<a href="<?= \yii\helpers\Url::to(["/cms/admin-cms-project/view", "pk" => $project->id]); ?>" data-pjax="0" style="border: 0;">
<img src="<?= \Yii::$app->imaging->thumbnailUrlOnRequest($project->cmsImage ? $project->cmsImage->src : \skeeks\cms\helpers\Image::getCapSrc(),
new \skeeks\cms\components\imaging\filters\Thumbnail([
'h' => $widget->prviewImageSize,
'w' => $widget->prviewImageSize,
'm' => \Imagine\Image\ManipulatorInterface::THUMBNAIL_OUTBOUND,
])); ?>" alt=""
class="sx-photo <?= $class; ?> sx-img-size-<?= $widget->prviewImageSize; ?>"
title="<?= $title; ?>"
data-toggle="tooltip"
data-html="true"
onclick='<?= new \yii\web\JsExpression(<<<JS
new sx.classes.backend.widgets.Action({$actionData}).go(); return false;
JS
); ?>'
>
</a>
<? else : ?>
<div class="sx-no-photo g-brd-gray-light-v4 sx-img-size-<?= $widget->prviewImageSize; ?>">
<a href="<?= \yii\helpers\Url::to(["/cms/admin-cms-project/view", "pk" => $project->id]); ?>" data-pjax="0" style="border: 0;"
onclick='<?= new \yii\web\JsExpression(<<<JS
new sx.classes.backend.widgets.Action({$actionData}).go(); return false;
JS
); ?>'
>
<?= \skeeks\cms\helpers\StringHelper::strtoupper(
\skeeks\cms\helpers\StringHelper::substr($project->name, 0, 2)
); ?>
</a>
</div>
<? endif; ?>
</div>
<div>
<?= \yii\helpers\Html::tag($widget->tagName, $project->asText, \yii\helpers\ArrayHelper::merge([
'data-toggle' => 'tooltip',
'data-html' => 'true',
'data-pjax' => '0',
'title' => $title,
'href' => \yii\helpers\Url::to(["/cms/admin-cms-project/view", "pk" => $project->id]),
'onclick' => new \yii\web\JsExpression(<<<JS
new sx.classes.backend.widgets.Action({$actionData}).go(); return false;
JS
)
], $widget->tagNameOptions)); ?>
<? if ($widget->isShowOnlyName === false) : ?>
<br/>
<div class="sx-employee">
<?= $project->is_private ? "Закрытый" : "Открытый"; ?>
</div>
<? endif; ?>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/forms/FieldSetWidget.php | src/widgets/forms/FieldSetWidget.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\widgets\forms;
use skeeks\cms\widgets\assets\FieldSetAsset;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\ActiveForm;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class FieldSetWidget extends Widget {
/**
* @var string
*/
public static $autoIdPrefix = 'field-set';
/**
* @var ActiveForm
*/
public $activeForm = null;
/**
* @var
*/
public $name;
/**
* @var array
*/
public $options = [];
/**
* @var array
*/
public $countentOptions = [];
/**
* @var array
*/
public $headerOptions = [];
/**
* @var bool
*/
public $isOpen = true;
/**
* Initializes the widget.
* This renders the form open tag.
*/
public function init()
{
parent::init();
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
$openedFromRequest = \Yii::$app->request->get($this->activeForm->id);
if ($openedFromRequest) {
if (!$this->isOpen && in_array($this->id, $openedFromRequest)) {
$this->isOpen = true;
}
if ($this->isOpen && !in_array($this->id, $openedFromRequest)) {
$this->isOpen = false;
}
}
self::registerAssets($this->activeForm);
if (!$this->isOpen) {
Html::addCssClass($this->options, " sx-field-set-hidden");
}
if (!isset($this->options['id'])) {
$this->options['id'] = $this->id;
}
Html::addCssClass($this->options, "sx-form-fieldset");
Html::addCssClass($this->countentOptions, "sx-form-fieldset-content");
Html::addCssClass($this->headerOptions, "sx-form-fieldset-title");
ob_start();
ob_implicit_flush(false);
}
static public $registerdForms = [];
static public function registerAssets(ActiveForm $activeForm)
{
if (isset(self::$registerdForms[$activeForm->id])) {
return true;
}
self::$registerdForms[$activeForm->id] = true;
FieldSetAsset::register(\Yii::$app->view);
$jsData = Json::encode([
'form-id' => $activeForm->id
]);
\Yii::$app->view->registerJs(<<<JS
new sx.classes.ActiveFormFieldSet({$jsData});
JS
);
}
/**
* Runs the widget.
* This registers the necessary JavaScript code and renders the form open and close tags.
* @throws InvalidCallException if `beginField()` and `endField()` calls are not matching.
*/
public function run()
{
/*if (!empty($this->_fields)) {
throw new InvalidCallException('Each beginField() should have a matching endField() call.');
}*/
$content = ob_get_clean();
$html = $this->_begin();
$html .= $content;
$html .= $this->_end();
return $html;
}
/**
* @var null
*/
private $_beginTag = null;
/**
* @var null
*/
private $_beginContentTag = null;
/**
* @return string
*/
protected function _begin() {
$tag = ArrayHelper::getValue($this->options, "tag", "div");
ArrayHelper::removeValue($this->options, "tag");
$this->_beginTag = $tag;
$html = Html::beginTag($tag, $this->options);
$tag = ArrayHelper::getValue($this->headerOptions, "tag", "div");
ArrayHelper::removeValue($this->headerOptions, "tag");
$html .= Html::tag($tag, $this->name, $this->headerOptions);
$tag = ArrayHelper::getValue($this->countentOptions, "tag", "div");
ArrayHelper::removeValue($this->countentOptions, "tag");
$this->_beginContentTag = $tag;
$html .= Html::beginTag($tag, $this->countentOptions);
return $html;
}
/**
* @return string
*/
protected function _end() {
$html = Html::endTag($this->_beginTag) . Html::endTag($this->_beginContentTag);
return $html;
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/StorageImage.php | src/widgets/formInputs/StorageImage.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 02.03.2015
*/
namespace skeeks\cms\widgets\formInputs;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\models\CmsStorageFile;
use skeeks\cms\models\StorageFile;
use yii\base\Exception;
use yii\bootstrap\Alert;
use yii\helpers\Json;
use yii\widgets\InputWidget;
/**
* @property CmsStorageFile $image
* Class StorageImage
* @package skeeks\cms\widgets\formInputs
*/
class StorageImage extends InputWidget
{
/**
* @var array
*/
public $clientOptions = [];
public $viewItemTemplate = null;
/**
* @param $cmsStorageFile
* @return string
*/
public function renderItem($cmsStorageFile)
{
return $this->render($this->viewItemTemplate, [
'model' => $cmsStorageFile
]);
}
/**
* @inheritdoc
*/
public function run()
{
try {
if (!$this->hasModel()) {
throw new Exception(\Yii::t('skeeks/cms', "Current widget works only in form with model"));
}
if ($this->model->isNewRecord) {
throw new Exception(\Yii::t('skeeks/cms', "The image can be downloaded after you save the form data"));
}
echo $this->render('storage-image', [
'model' => $this->model,
'widget' => $this,
]);
} catch (\Exception $e) {
echo Alert::widget([
'options' => [
'class' => 'alert-warning',
],
'body' => $e->getMessage()
]);
}
}
/**
* @return null|StorageFile
*/
public function getImage()
{
$imageId = $this->model->{$this->attribute};
if (!$imageId) {
return null;
}
return StorageFile::findOne($imageId);
}
public function getJsonString()
{
return Json::encode([
'backendUrl' => UrlHelper::construct('/cms/admin-storage-files/link-to-model')->enableAdmin()->toString(),
'modelId' => $this->model->id,
'modelClassName' => $this->model->className(),
'modelAttribute' => $this->attribute,
]);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/EditedSelect.php | src/widgets/formInputs/EditedSelect.php | <?php
/**
* Селект в который можно добавлять записи
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 16.03.2015
*/
namespace skeeks\cms\widgets\formInputs;
use skeeks\cms\Exception;
use skeeks\cms\models\Publication;
use skeeks\cms\modules\admin\widgets\Pjax;
use skeeks\widget\chosen\Chosen;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
use Yii;
/**
* @deprecated
* Class EditedSelect
* @package skeeks\cms\widgets\formInputs
*/
class EditedSelect extends Chosen
{
protected $_pjaxId = '';
/**
* @var string
*/
public $createAction = 'create';
public $updateAction = 'update';
public $controllerRoute = '';
public $additionalData = [];
public function init()
{
$this->_pjaxId = 'pjax-' . $this->id;
Pjax::begin([
'id' => $this->_pjaxId
]);
parent::init();
}
/**
* @inheritdoc
*/
public function run()
{
echo "<div class='row'>";
echo "<div class='col-md-6'>";
if ($this->hasModel()) {
echo Html::activeListBox($this->model, $this->attribute, $this->items, $this->options);
} else {
echo Html::listBox($this->name, $this->value, $this->items, $this->options);
}
echo "</div>";
echo "<div class='col-md-6'>";
$createUrl = (string)\skeeks\cms\backend\helpers\BackendUrlHelper::createByParams([$this->controllerRoute . '/' . $this->createAction])
->merge($this->additionalData)
->enableEmptyLayout()
->enableNoActions()
->url;
$updateUrl = (string)\skeeks\cms\backend\helpers\BackendUrlHelper::createByParams([$this->controllerRoute . '/' . $this->updateAction])
->merge($this->additionalData)
->enableEmptyLayout()
->url;
$create_w = \Yii::t('skeeks/cms', 'Create');
$edit_w = \Yii::t('skeeks/cms', 'Edit');
echo <<<HTML
<a href="{$createUrl}" class="btn btn-default sx-btn-create sx-btn-controll" ><span class="fa fa-plus"></span> {$create_w}</a>
<a href="{$updateUrl}" class="btn btn-default sx-btn-update sx-btn-controll" ><span class="fa fa-edit"></span> {$edit_w}</a>
HTML;
echo "</div>";
echo "</div>";
Pjax::end();
$options = [
'multiple' => (int)$this->multiple,
];
$optionsString = Json::encode($options);
$this->view->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.FormElementEditedSelect = sx.classes.Widget.extend({
_init: function()
{},
getWrapper: function()
{
return $(this._wrapper);
},
_onDomReady: function()
{
var self = this;
$(this.getWrapper()).on('change', 'select', function()
{
self.updateButtons();
});
$(this.getWrapper()).on('click', '.sx-btn-create', function()
{
var windowWidget = new sx.classes.Window($(this).attr('href'));
windowWidget.bind('close', function(e, data)
{
self.reload();
});
windowWidget.open();
return false;
});
$(this.getWrapper()).on('click', '.sx-btn-update', function()
{
var windowWidget = new sx.classes.Window($(this).attr('href') + '&pk=' + $('select', self.getWrapper()).val());
windowWidget.bind('close', function(e, data)
{
self.reload();
});
windowWidget.open();
return false;
});
self.updateButtons();
},
_onWindowReady: function()
{},
updateButtons: function()
{
var self = this;
if (!self.get('multiple'))
{
if ($('select', this.getWrapper()).val())
{
self.showUpdateControll();
} else
{
self.hideUpdateControll();
}
} else
{
self.hideUpdateControll();
}
return this;
},
/**
*
* @returns {sx.classes.FormElementEditedSelect}
*/
hideUpdateControll: function()
{
$('.sx-btn-update', this.getWrapper()).hide();
return this;
},
/**
*
* @returns {sx.classes.FormElementEditedSelect}
*/
showUpdateControll: function()
{
$('.sx-btn-update', this.getWrapper()).show();
return this;
},
reload: function()
{
var self = this;
$.pjax.reload("#" + this.getWrapper().attr('id'), {});
_.delay(function()
{
self.updateButtons();
}, 500);
}
});
new sx.classes.FormElementEditedSelect('#{$this->_pjaxId}', {$optionsString});
})(sx, sx.$, sx._);
JS
);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/SmartDurationInputWidget.php | src/widgets/formInputs/SmartDurationInputWidget.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 02.03.2015
*/
namespace skeeks\cms\widgets\formInputs;
use skeeks\cms\base\InputWidget;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class SmartDurationInputWidget extends InputWidget
{
static public $autoIdPrefix = "SmartTimeInputWidget";
public $viewFile = 'smart-duration';
/**
* @var array
*/
public $defaultOptions = [
'type' => 'text',
'class' => 'form-control',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/ModelStorageFiles.php | src/widgets/formInputs/ModelStorageFiles.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 02.03.2015
*/
namespace skeeks\cms\widgets\formInputs;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\models\CmsStorageFile;
use skeeks\cms\models\StorageFile;
use yii\base\Exception;
use yii\bootstrap\Alert;
use yii\helpers\Json;
use yii\widgets\InputWidget;
/**
*
*
*
* <?= $form->field($model, 'images')->widget(
* \skeeks\cms\widgets\formInputs\ModelStorageFiles::className(),
* [
* 'backendUrl' => \yii\helpers\Url::to(['/cms/storage-files/link-to-models']),
* 'viewItemTemplate' => '',
* 'controllWidgetOptions' => [
* 'backendSimpleUploadUrl' => \yii\helpers\Url::to(['/cms/storage-files/upload']),
* 'backendRemoteUploadUrl' => \yii\helpers\Url::to(['/cms/storage-files/remote-upload']),
* ],
* ]
* ); ?>
*
*
* @property StorageFile[] $files
* Class StorageImages
* @package skeeks\cms\widgets\formInputs
*/
class ModelStorageFiles extends InputWidget
{
/**
* @var array
*/
public $clientOptions = [];
/**
* @var null
*/
public $viewItemTemplate = null;
/**
* @var string url to communicate with the model pictures
* cms/storage-files/link-to-models
* cms/admin-storage-files/link-to-models
*/
public $backendUrl = null;
/**
* @var array
*/
public $controllWidgetOptions = [];
public function init()
{
parent::init();
if ($this->backendUrl === null) {
$this->backendUrl = UrlHelper::construct('/cms/admin-storage-files/link-to-models')->enableAdmin()->toString();
}
}
/**
* @param $cmsStorageFile
* @return string
*/
public function renderItem($cmsStorageFile)
{
return $this->render($this->viewItemTemplate, [
'model' => $cmsStorageFile
]);
}
/**
* @inheritdoc
*/
public function run()
{
try {
if (!$this->hasModel()) {
throw new Exception(\Yii::t('skeeks/cms', "Current widget works only in form with model"));
}
if ($this->model->isNewRecord) {
throw new Exception(\Yii::t('skeeks/cms', "Images can be downloaded after you save the form data"));
}
if (!$this->model->hasProperty($this->attribute)) {
throw new Exception("Relation {$this->attribute} не найдена");
}
echo $this->render('model-storage-files', [
'model' => $this->model,
'widget' => $this,
]);
} catch (\Exception $e) {
echo Alert::widget([
'options' => [
'class' => 'alert-warning',
],
'body' => $e->getMessage()
]);
}
}
/**
* @return null|StorageFile[]
*/
public function getFiles()
{
return $this->model->{$this->attribute};
}
public function getJsonString()
{
return Json::encode([
'backendUrl' => $this->backendUrl,
'modelId' => $this->model->id,
'modelClassName' => $this->model->className(),
'modelRelation' => $this->attribute,
]);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/daterange/DaterangeInputWidget.php | src/widgets/formInputs/daterange/DaterangeInputWidget.php | <?php
/**
* SelectTree
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 13.11.2014
* @since 1.0.0
*/
namespace skeeks\cms\widgets\formInputs\daterange;
use skeeks\cms\Exception;
use skeeks\cms\modules\admin\Module;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\JsExpression;
use yii\widgets\InputWidget;
/**
*
*
* <?= $form->field($model, 'treeIds')->widget(
* \skeeks\cms\widgets\formInputs\selectTree\SelectTreeInputWidget::class,
* [
* 'multiple' => true
* ]
* ); ?>
*
*
*
* Class SelectTreeInputWidget
*
* @package skeeks\cms\widgets\formInputs\selectTree
*
* @see https://www.daterangepicker.com/
* @see https://github.com/dangrossman/daterangepicker
*/
class DaterangeInputWidget extends InputWidget
{
public static $autoIdPrefix = 'SelectTreeInputWidget';
/**
* @var array
*/
public $clientOptions = [];
public $jsConfigPrepend = [];
public $jsConfigAppend = [];
protected $_daterangepickerDefaultConfig = [];
/**
* @var array
*/
public $wrapperOptions = [];
public $defaultOptions = [
'autocomplete' => 'off',
];
/**
* @var bool
*/
public $multiple = false;
public function init()
{
$this->_daterangepickerDefaultConfig = [
"autoUpdateInput" => false,
"locale" => [
"format" => "DD.MM.YYYY",
"separator" => " - ",
"applyLabel" => "Применить",
"cancelLabel" => "Сбросить фильтр",
"fromLabel" => "от",
"toLabel" => "до",
"customRangeLabel" => "Диапазон",
"weekLabel" => "W",
"daysOfWeek" => [
"Вс",
"Пн",
"Вт",
"Ср",
"Чт",
"Пт",
"Сб",
],
"monthNames" => [
"Январь",
"Февраль",
"Март",
"Апрель",
"Май",
"Июнь",
"Июль",
"Август",
"Сентябрь",
"Октябрь",
"Ноябрь",
"Декабрь",
],
"firstDay" => 1,
],
"ranges" => [
"Сегодня" => new JsExpression("[moment(), moment()]"),
"Вчера" => new JsExpression("[moment().subtract(1, 'days'), moment().subtract(1, 'days')]"),
"Последние 7 дней" => new JsExpression("[moment().subtract(6, 'days'), moment()]"),
"Последние 30 дней" => new JsExpression("[moment().subtract(29, 'days'), moment()]"),
"Этот месяц" => new JsExpression("[moment().startOf('month'), moment().endOf('month')]"),
"Прошлый месяц" => new JsExpression("[moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]"),
"Этот год" => new JsExpression("[moment().startOf('year'), moment().endOf('year')]"),
"Прошлый год" => new JsExpression("[moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]"),
]
];
$this->wrapperOptions['id'] = $this->id."-wrapper";
$this->clientOptions['id'] = $this->id;
$this->clientOptions['wrapperid'] = $this->wrapperOptions['id'];
Html::addCssClass($this->wrapperOptions, "sx-daterange");
parent::init();
}
/**
* @inheritdoc
*/
public function run()
{
$this->options = ArrayHelper::merge($this->defaultOptions, $this->options);
if ($this->hasModel()) {
if (!array_key_exists('id', $this->options)) {
$this->clientOptions['inputId'] = Html::getInputId($this->model, $this->attribute);
} else {
$this->clientOptions['inputId'] = $this->options['id'];
}
$element = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
//TODO: реализовать для работы без модели
$element = Html::textInput($this->name, $this->value, $this->options);
}
$this->registerAssets();
$jsConfig = $this->_daterangepickerDefaultConfig;
if ($this->jsConfigPrepend) {
$jsConfig = ArrayHelper::merge($this->jsConfigPrepend, $jsConfig);
}
if ($this->jsConfigAppend) {
$jsConfig = ArrayHelper::merge($jsConfig, $this->jsConfigAppend);
}
echo $this->render('daterange', [
'widget' => $this,
'element' => $element,
'jsConfig' => $jsConfig,
]);
}
/**
* @return $this
*/
public function registerAssets()
{
DaterangeInputWidgetAsset::register($this->view);
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/widgets/formInputs/daterange/DaterangeInputWidgetAsset.php | src/widgets/formInputs/daterange/DaterangeInputWidgetAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
namespace skeeks\cms\widgets\formInputs\daterange;
use Yii;
use yii\web\AssetBundle;
use yii\web\JqueryAsset;
/**
* Class ComboTextInputWidgetAsset
* @package skeeks\cms\widgets\formInputs\comboText
*/
class DaterangeInputWidgetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/formInputs/daterange/assets/src';
public $css = [
/*'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css',*/
'css/daterangepicker-3.1.css'
];
public $js = [
/* 'https://cdn.jsdelivr.net/momentjs/latest/moment.min.js',
'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js',*/
'js/moment-2.18.1.min.js',
'js/daterangepicker-3.1.min.js',
];
public $depends = [
JqueryAsset::class
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/daterange/views/daterange.php | src/widgets/formInputs/daterange/views/daterange.php | <?
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
/* @var $this yii\web\View */
/* @var $jsConfig [] */
/* @var $widget \skeeks\cms\widgets\formInputs\daterange\DaterangeInputWidget */
$options = $widget->clientOptions;
$clientOptions = \yii\helpers\Json::encode($options);
?>
<?php echo \yii\helpers\Html::beginTag("div", $widget->wrapperOptions) ?>
<?php echo $element; ?>
<?php echo \yii\helpers\Html::endTag("div"); ?>
<?
$jsDaterangeConfig = \yii\helpers\Json::encode($jsConfig);
$this->registerJs(<<<JS
$(function() {
var jsDateRange = {$clientOptions};
var wrapperId = jsDateRange['wrapperid'];
var jInputWrapper = $("#" + wrapperId);
var jInput = $("input", jInputWrapper);
jInput.daterangepicker({$jsDaterangeConfig});
jInput.on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY') + ' - ' + picker.endDate.format('DD/MM/YYYY')).trigger("change");
});
jInput.on('cancel.daterangepicker', function(ev, picker) {
$(this).val('').trigger("change");
});
});
JS
)
?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/comboText/ComboTextInputWidget.php | src/widgets/formInputs/comboText/ComboTextInputWidget.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
namespace skeeks\cms\widgets\formInputs\comboText;
use skeeks\cms\Exception;
use skeeks\cms\helpers\UrlHelper;
use skeeks\widget\codemirror\CodemirrorWidget;
use skeeks\yii2\ckeditor\CKEditorPresets;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
use Yii;
/**
* Class ComboTextInputWidget
* @package skeeks\cms\widgets\formInputs\comboText
*/
class ComboTextInputWidget extends InputWidget
{
const CONTROLL_TEXT = "text";
const CONTROLL_EDITOR = "editor";
const CONTROLL_HTML = "html";
public static function editors()
{
return [
self::CONTROLL_TEXT => \Yii::t('skeeks/cms', 'Text'),
self::CONTROLL_EDITOR => \Yii::t('skeeks/cms', 'Visual Editor'),
self::CONTROLL_HTML => 'HTML',
];
}
public $defaultEditor = "text";
/**
* @var array Опции текстового поля по умолчанию.
*/
public $defaultOptions = [
'class' => 'form-control',
'rows' => '20',
];
/**
* @var array Общие js опции текущего виджета
*/
public $clientOptions = [];
/**
* @var string название поля, в котором будет храниться выбранный тип редактора.
* Если не будет указан, то редактор по умолчанию будет выбран из настроек.
*/
public $modelAttributeSaveType = "";
/**
* @var array Опции для CKEditor
*/
public $ckeditorOptions = [];
/**
* @var array Опции для CodeMirror
*/
public $codemirrorOptions = [];
//TODO: сделать etter и зактрытый setter
/**
* @var \skeeks\cms\widgets\formInputs\ckeditor\Ckeditor
*/
public $ckeditor = null;
/**
* @var CodemirrorWidget
*/
public $codemirror = null;
public function init()
{
parent::init();
if (!array_key_exists('id', $this->clientOptions)) {
$this->clientOptions['id'] = $this->id;
}
}
/**
* @inheritdoc
*/
public function run()
{
$this->options = ArrayHelper::merge($this->defaultOptions, $this->options);
if ($this->hasModel()) {
if (!array_key_exists('id', $this->options)) {
$this->clientOptions['inputId'] = Html::getInputId($model, $attribute);
} else {
$this->clientOptions['inputId'] = $this->options['id'];
}
$textarea = Html::activeTextarea($this->model, $this->attribute, $this->options);
} else {
//TODO: реализовать для работы без модели
echo Html::textarea($this->name, $this->value, $this->options);
return;
}
$this->registerPlugin();
echo $this->render('combo-text', [
'widget' => $this,
'textarea' => $textarea
]);
}
/**
* Registers CKEditor plugin
*/
protected function registerPlugin()
{
$view = $this->getView();
$this->ckeditor = new \skeeks\cms\widgets\formInputs\ckeditor\Ckeditor(ArrayHelper::merge([
'model' => $this->model,
'attribute' => $this->attribute,
'relatedModel' => $this->model,
], $this->ckeditorOptions));
$this->codemirror = new CodemirrorWidget(ArrayHelper::merge([
'model' => $this->model,
'attribute' => $this->attribute,
'preset' => 'htmlmixed',
'assets' =>
[
\skeeks\widget\codemirror\CodemirrorAsset::THEME_NIGHT
],
'clientOptions' =>
[
'theme' => 'night'
],
], $this->codemirrorOptions));
$this->ckeditor->registerAssets();
$this->codemirror->registerAssets();
$this->clientOptions['ckeditor'] = $this->ckeditor->clientOptions;
$this->clientOptions['codemirror'] = $this->codemirror->clientOptions;
ComboTextInputWidgetAsset::register($this->view);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/comboText/ComboTextInputWidgetAsset.php | src/widgets/formInputs/comboText/ComboTextInputWidgetAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
namespace skeeks\cms\widgets\formInputs\comboText;
use Yii;
use yii\web\AssetBundle;
/**
* Class ComboTextInputWidgetAsset
* @package skeeks\cms\widgets\formInputs\comboText
*/
class ComboTextInputWidgetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/formInputs/comboText/assets';
public $css = [];
public $js =
[
'combo-widget.js',
];
public $depends = [
'\skeeks\sx\assets\Core',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/comboText/views/combo-text.php | src/widgets/formInputs/comboText/views/combo-text.php | <?
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\formInputs\comboText\ComboTextInputWidget */
$options = $widget->clientOptions;
$clientOptions = \yii\helpers\Json::encode($options);
?>
<div id="<?= $widget->id; ?>">
<div class="sx-select-controll">
<?php if ($widget->modelAttributeSaveType) : ?>
<?= \yii\helpers\Html::activeRadioList($widget->model, $widget->modelAttributeSaveType,
\skeeks\cms\widgets\formInputs\comboText\ComboTextInputWidget::editors()) ?>
<?php else
: ?>
<?= \yii\helpers\Html::radioList(
$widget->id . '-radio',
$widget->defaultEditor,
\skeeks\cms\widgets\formInputs\comboText\ComboTextInputWidget::editors()
) ?>
<?php endif;
?>
</div>
<div class="sx-controll">
<?= $textarea; ?>
</div>
</div>
<?
//TODO: убрать в файл
$this->registerCss(<<<CSS
.CodeMirror
{
height: 400px;
}
CSS
);
$this->registerJs(<<<JS
(function(sx, $, _)
{
new sx.classes.combotext.ComboTextInputWidget({$clientOptions});
})(sx, sx.$, sx._);
JS
)
?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/selectTree/SelectTree.php | src/widgets/formInputs/selectTree/SelectTree.php | <?php
/**
* SelectTree
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 13.11.2014
* @since 1.0.0
*/
namespace skeeks\cms\widgets\formInputs\selectTree;
use skeeks\cms\Exception;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\models\Tree;
use skeeks\cms\modules\admin\Module;
use skeeks\cms\modules\admin\widgets\ActiveForm;
use skeeks\cms\themes\unify\admin\assets\UnifyAdminIframeAsset;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
use Yii;
/**
* Class Widget
* @package skeeks\cms\widgets\formInputs\selectTree
*/
class SelectTree extends InputWidget
{
/**
* @var array the options for the Bootstrap File Input plugin. Default options have exporting enabled.
* Please refer to the Bootstrap File Input plugin Web page for possible options.
* @see http://plugins.krajee.com/file-input#options
*/
public $clientOptions = [];
public $attributeSingle = 'tree_id';
public $attributeMulti = 'tree_ids';
const MOD_COMBO = 'combo';
const MOD_SINGLE = 'single';
const MOD_MULTI = 'multi';
public $mode = self::MOD_COMBO;
/**
* Берем поведения модели
*
*/
private function _initAndValidate()
{
if (!$this->hasModel()) {
throw new Exception(\Yii::t('skeeks/cms', "This file is intended only for forms model"));
}
}
/**
* @inheritdoc
*/
public function run()
{
try {
UnifyAdminIframeAsset::register($this->view);
$this->_initAndValidate();
$valueArray = [];
$trees = [];
$valueSingle = "";
$select = "";
$singleInput = "";
if (in_array($this->mode, [self::MOD_COMBO, self::MOD_MULTI])) {
$valueArray = Html::getAttributeValue($this->model, $this->attribute);
$select = Html::activeListBox($this->model, $this->attribute, ['16' => "16"], [
'multiple' => true,
'class' => 'sx-controll-element sx-multi',
'style' => 'display: none;'
]);
$trees = Tree::find()->where(['id' => $valueArray])->all();
}
if (in_array($this->mode, [self::MOD_COMBO, self::MOD_SINGLE])) {
$singleInput = Html::activeInput("hidden", $this->model, $this->attributeSingle, [
'class' => 'sx-single'
]);
$valueSingle = Html::getAttributeValue($this->model, $this->attributeSingle);
}
$src = \skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(['/cms/admin-tools/tree'])
->merge([
'mode' => $this->mode
])
->enableEmptyLayout()
->enableNoActions()
->url;
$id = "sx-id-" . md5(serialize([
$this->clientOptions,
$this->mode,
$this->attributeMulti,
$this->attributeSingle
]));
$selected = [];
foreach ($trees as $tree) {
$selected[] = $tree->id;
}
return $this->render('widget', [
'widget' => $this,
'id' => $id,
'select' => $select,
'src' => $src,
'valueSingle' => $valueSingle,
'idSmartFrame' => $id . "-smart-frame",
'singleInput' => $singleInput,
'clientOptions' => Json::encode(
[
'idSmartFrame' => $id . "-smart-frame",
'src' => $src,
'name' => $id,
'id' => $id,
'selected' => $selected,
'valueSingle' => $valueSingle
]
)
]);
//$this->registerClientScript();
} catch (Exception $e) {
echo $e->getMessage();
}
}
/**
* Registers Bootstrap File Input plugin
*/
public function registerClientScript()
{
$view = $this->getView();
Asset::register($view);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/selectTree/SelectTreeInputWidget.php | src/widgets/formInputs/selectTree/SelectTreeInputWidget.php | <?php
/**
* SelectTree
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 13.11.2014
* @since 1.0.0
*/
namespace skeeks\cms\widgets\formInputs\selectTree;
use skeeks\cms\Exception;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\models\CmsTree;
use skeeks\cms\models\Tree;
use skeeks\cms\modules\admin\Module;
use skeeks\cms\modules\admin\widgets\ActiveForm;
use skeeks\cms\widgets\formInputs\selectTree\assets\SelectTreeInputWidgetAsset;
use skeeks\cms\widgets\Pjax;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
use Yii;
/**
*
*
* <?= $form->field($model, 'treeIds')->widget(
* \skeeks\cms\widgets\formInputs\selectTree\SelectTreeInputWidget::class,
* [
* 'multiple' => true
* ]
* ); ?>
*
*
* @property CmsTree[] $sections
*
* Class SelectTreeInputWidget
*
* @package skeeks\cms\widgets\formInputs\selectTree
*/
class SelectTreeInputWidget extends InputWidget
{
public static $autoIdPrefix = 'SelectTreeInputWidget';
/**
* @var array
*/
public $clientOptions = [];
/**
* @var array
*/
public $wrapperOptions = [];
/**
* @see skeeks\cms\widgets\tree\CmsTreeWidget options
*
* @var array
*/
public $treeWidgetOptions = [];
public $treeWidgetClass = 'skeeks\cms\widgets\tree\CmsTreeWidget';
/**
* @var bool
*/
public $multiple = false;
/**
* @var null|callable
*/
public $isAllowNodeSelectCallback = null;
public function init()
{
$this->treeWidgetOptions = ArrayHelper::merge([
"models" => [],
//"isSearchEnabled" => false,
"sessionName" => 'select-' . (int)$this->multiple,
"viewNodeContentFile" => '@skeeks/cms/widgets/formInputs/selectTree/views/_tree-node',
'pjaxOptions' => [
'enablePushState' => false,
],
'contextData' => [
'selectTreeInputWidget' => $this
]
], $this->treeWidgetOptions);
$this->wrapperOptions['id'] = $this->id . "-wrapper";
$this->clientOptions['id'] = $this->id;
$this->clientOptions['wrapperid'] = $this->wrapperOptions['id'];
parent::init();
}
/**
* @inheritdoc
*/
public function run()
{
Html::addCssClass($this->wrapperOptions, "sx-select-tree-input-widget");
if ($this->multiple) {
Html::addCssClass($this->wrapperOptions, "sx-multi-mode");
} else {
Html::addCssClass($this->wrapperOptions, "sx-single-mode");
}
$value = $this->model->{$this->attribute};
$items = $value;
if ($value && is_string($value) || is_int($value)) {
$items = [$value => $value];
} else if (is_array($value)) {
$newValue = [];
foreach ($value as $k => $v) {
if ($v instanceof CmsTree) {
$newValue[$v->id] = $v->id;
} else {
$newValue[$v] = $v;
}
}
$items = $newValue;
}
if (!$items) {
$items = [];
}
if (is_array($items)) {
$tmpItems = [];
foreach ($items as $key => $item) {
if ($item instanceof CmsTree) {
$tmpItems[$item->id] = $item->id;
}
}
if ($tmpItems) {
$items = $tmpItems;
}
}
$this->options['multiple'] = $this->multiple;
Html::addCssClass($this->options, 'sx-widget-element');
$select = Html::activeListBox($this->model, $this->attribute, $items, $this->options);
$this->clientOptions['value'] = $value;
$this->clientOptions['multiple'] = (int)$this->multiple;
$this->registerAssets();
return $this->render('select-tree-widget', [
'elementForm' => $select
]);
}
/**
* @return $this
*/
public function registerAssets()
{
SelectTreeInputWidgetAsset::register($this->view);
return $this;
}
/**
* @param $model
*
* @return string
*/
public function getNodeName($tree)
{
if ($models = ArrayHelper::getValue($this->treeWidgetOptions, 'models')) {
$model = $models[0];
$rootLevel = $model->level;
/**
* @var \skeeks\cms\models\CmsTree $tree
*/
$name = $tree->name;
if ($tree->parents) {
$parents = $tree->getParents()->andWhere(['>=', 'level', $rootLevel])->all();
if ($parents) {
$name = implode(" / ", \yii\helpers\ArrayHelper::map($parents, 'id', 'name'));
$name .= " / " . $tree->name;
}
}
return $name;
} else {
$rootLevel = 0;
/**
* @var \skeeks\cms\models\CmsTree $tree
*/
$name = $tree->name;
if ($tree->parents) {
$parents = $tree->getParents()->andWhere(['>=', 'level', $rootLevel])->all();
if ($parents) {
$name = implode(" / ", \yii\helpers\ArrayHelper::map($parents, 'id', 'name'));
$name .= " / " . $tree->name;
}
}
return $name;
}
return $tree->name;
}
/**
* @param $model
*
* @return string
*/
public function renderNodeControll($model)
{
$disabled = false;
if ($this->isAllowNodeSelectCallback && is_callable($this->isAllowNodeSelectCallback)) {
$function = $this->isAllowNodeSelectCallback;
if (!$function($model)) {
$disabled = "disabled";
}
}
if ($this->multiple) {
$controllElement = Html::checkbox($this->id . '-checkbox', false, [
'value' => $model->id,
'class' => 'sx-checkbox',
'disabled' => $disabled,
'style' => 'float: left; margin-left: 5px; margin-right: 5px; margin-top: 5px;',
]);
} else {
$controllElement = Html::radio($this->id . '-radio', false, [
'value' => $model->id,
'class' => 'sx-radio',
'disabled' => $disabled,
'style' => 'float: left; margin-left: 5px; margin-right: 5px; margin-top: 5px;',
]);
}
return $controllElement;
}
/**
* @param $model
*
* @return string
*/
public function renderNodeName($model)
{
$result = $model->name;
$additionalName = '';
if ($model->level == 0) {
$site = \skeeks\cms\models\CmsSite::findOne(['id' => $model->cms_site_id]);
if ($site) {
$additionalName = $site->name;
}
}
if ($additionalName) {
$result .= " [{$additionalName}]";
}
return $result;
}
/**
* @return CmsTree[]
*/
public function getSections()
{
$value = $this->model->{$this->attribute};
if (!$value) {
return [];
}
$items = $value;
if (is_string($value) || is_int($value)) {
$items = [$value => $value];
}
if (is_array($items)) {
$tmpItems = [];
foreach ($items as $key => $item) {
if ($item instanceof CmsTree) {
$tmpItems[$item->id] = $item->id;
}
}
if ($tmpItems) {
$items = $tmpItems;
}
}
return CmsTree::findAll(["id" => $items]);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/selectTree/views/widget.php | src/widgets/formInputs/selectTree/views/widget.php | <?php
/**
* widget
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 13.11.2014
* @since 1.0.0
*/
use \skeeks\cms\widgets\formInputs\selectTree\SelectTree;
/**
* @var \skeeks\cms\widgets\formInputs\selectTree\SelectTree $widget
*/
?>
<div id="<?= $id; ?>">
<p>
<?php if ($widget->mode == SelectTree::MOD_COMBO) : ?>
<small><?= \Yii::t('skeeks/cms',
'Circle — the main section (you can choose one section, it will affect the construction of bread crumbs)') ?></small>
<br/>
<small><?= \Yii::t('skeeks/cms',
'The square - an additional section (you can mark several additional sections)') ?></small>
<?php elseif ($widget->mode == SelectTree::MOD_MULTI) : ?>
<small><?= \Yii::t('skeeks/cms',
'The square - an additional section (you can mark several additional sections)') ?></small>
<?php endif; ?>
</p>
<iframe data-src="<?= $src; ?>" width="100%;" height="200px;" id="<?= $idSmartFrame; ?>"></iframe>
<div class="sx-selected">
<?= $select; ?>
<?= $singleInput; ?>
</div>
</div>
<?php
\skeeks\cms\themes\unify\admin\assets\UnifyAdminIframeAsset::register($this);
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.createNamespace('classes.app', sx);
sx.classes.app.TreeSelect = sx.classes.Component.extend({
_init: function()
{
var self = this;
console.log(this.get('idSmartFrame'));
this.Iframe = new sx.classes.Iframe(this.get('idSmartFrame'), {
'autoHeight' : true,
'heightSelector' : 'main'
});
this.Iframe.onSxReady(function()
{
if (self.Iframe.sx.Tree)
{
self.Iframe.sx.Tree.bind('select', function(e, data)
{
self.addTrees(data.selected);
});
self.Iframe.sx.Tree.bind('selectSingle', function(e, data)
{
self.JsingleInput.val(data.id);
});
}
});
},
/**
* @returns {*|HTMLElement}
*/
getWrapper: function()
{
return $('#' + this.get('id'));
},
_onDomReady: function()
{
var self = this;
this.JsingleInput = $('input.sx-single', this.getWrapper());
this.JmultiInput = $('select.sx-multi', this.getWrapper());
if (this.get('selected'))
{
this.addTrees(this.get('selected'));
}
this.Iframe.onSxReady(function()
{
if (self.Iframe.sx.Tree)
{
self.Iframe.sx.Tree.setSingle(self.JsingleInput.val());
self.Iframe.sx.Tree.setSelect(self.JmultiInput.val());
}
});
_.delay(function()
{
$('#' + self.get('idSmartFrame')).attr('src', $('#' + self.get('idSmartFrame')).data('src'));
}, 200);
},
addTrees: function(data)
{
var self = this;
this.getWrapper().find('.sx-controll-element').empty();
_.each(data, function(value, key)
{
self.getWrapper().find('.sx-controll-element').append(
$("<option>", {
'value' : value,
'selected' : 'selected'
}).text('text')
);
});
},
});
new sx.classes.app.TreeSelect({$clientOptions});
})(sx, sx.$, sx._);
JS
); ?> | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/selectTree/views/_tree-node.php | src/widgets/formInputs/selectTree/views/_tree-node.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 18.12.2016
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\tree\CmsTreeWidget */
/* @var $model \skeeks\cms\models\CmsTree */
/* @var $selectTreeInputWidget \skeeks\cms\widgets\formInputs\selectTree\DaterangeInputWidget */
$widget = $this->context;
$selectTreeInputWidget = \yii\helpers\ArrayHelper::getValue($widget->contextData, 'selectTreeInputWidget');
?>
<?= $selectTreeInputWidget->renderNodeControll($model); ?>
<div class="sx-label-node level-<?= $model->level; ?> status-<?= $model->active; ?>">
<? if ($model->level == 0) : ?>
<i class="fas fa-home"></i>
<? elseif ($model->redirectTree) : ?>
<i class="fas fa-directions" data-toggle="tooltip" title="<?= $model->redirect_code ?> редирект в раздел: <?= $model->redirectTree->fullName; ?>"></i>
<? elseif ($model->redirect) : ?>
<i class="fas fa-directions" data-toggle="tooltip" title="<?= $model->redirect_code ?> редирект по url: <?= $model->redirect; ?>"></i>
<? elseif ($widget->isOpenNode($model)) : ?>
<i class="far fa-folder-open"></i>
<? else : ?>
<i class="far fa-folder"></i>
<? endif; ?>
<a href="<?= $widget->getOpenCloseLink($model); ?>"><?= $selectTreeInputWidget->renderNodeName($model); ?></a>
</div>
<!-- Possible actions -->
<!--<div class="sx-controll-node row">
<div class="pull-left sx-controll-act">
<a href="<?php /*= $model->absoluteUrl; */ ?>" target="_blank" class="btn-tree-node-controll btn btn-default btn-sm show-at-site" title="<?php /*= \Yii::t('skeeks/cms',"Show at site"); */ ?>">
<span class="fa fa-eye"></span>
</a>
</div>
</div>-->
<?php /* if ($model->treeType) : */ ?><!--
<div class="pull-right sx-tree-type">
<?php /*= $model->treeType->name; */ ?>
</div>
--><?php /* endif; */ ?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/selectTree/views/select-tree-widget.php | src/widgets/formInputs/selectTree/views/select-tree-widget.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.12.2016
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\formInputs\selectTree\DaterangeInputWidget */
$widget = $this->context;
?>
<?= \yii\helpers\Html::beginTag('div', $widget->wrapperOptions); ?>
<?= $elementForm; ?>
<div class="row">
<div class="col-md-12">
<div class="sx-selected-tree-input">
<ul class="sx-selected">
<?php if ($widget->sections) : ?>
<?php foreach ($widget->sections as $tree) : ?>
<li data-id="<?= $tree->id; ?>">
<div class="sx-selected-value" data-href="<?= $tree->url; ?>" title="<?= $widget->getNodeName($tree); ?>">
<?= $tree->name; ?>
</div>
<div class="sx-close-btn pull-right">×</div>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
</div>
<?php /*echo $widget->sections ? "style='display: none;'" : ""; */?>
<div class="col-md-12 sx-select-tree" style='display: none;'>
<div class="col-md-12 sx-select-tree-widget">
<?php $treeWidgetClass = $widget->treeWidgetClass; ?>
<?php $widgetTree = $treeWidgetClass::begin($widget->treeWidgetOptions); ?>
<?
$widget->clientOptions['pjaxid'] = $widgetTree->pjax->id;
$options = \yii\helpers\Json::encode($widget->clientOptions);
if ($widget->multiple) {
$this->registerJs(<<<JS
(function(window, sx, $, _)
{
new sx.classes.treeinput.SelectTreeInputMultiple({$options});
})(window, sx, sx.$, sx._);
JS
);
} else {
$this->registerJs(<<<JS
(function(window, sx, $, _)
{
new sx.classes.treeinput.SelectTreeInputSingle({$options});
})(window, sx, sx.$, sx._);
JS
);
}
?>
<?
$className = $widgetTree->className();
$className::end();
?>
</div>
</div>
</div>
<?= \yii\helpers\Html::endTag('div'); ?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/selectTree/assets/SelectTreeInputWidgetAsset.php | src/widgets/formInputs/selectTree/assets/SelectTreeInputWidgetAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.12.2016
*/
namespace skeeks\cms\widgets\formInputs\selectTree\assets;
use yii\web\AssetBundle;
/**
* Class SelectTreeInputWidgetAsset
*
* @package skeeks\cms\widgets\formInputs\selectTree\assets
*/
class SelectTreeInputWidgetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/formInputs/selectTree/assets/src';
public $css = [
'css/select-tree.css',
];
public $js = [
'js/select-tree.js',
];
public $depends = [
'skeeks\sx\assets\Core',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/ckeditor/Ckeditor.php | src/widgets/formInputs/ckeditor/Ckeditor.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.04.2015
*/
namespace skeeks\cms\widgets\formInputs\ckeditor;
use skeeks\cms\backend\helpers\BackendUrlHelper;
use skeeks\cms\Exception;
use skeeks\yii2\ckeditor\CKEditorWidget;
use yii\helpers\ArrayHelper;
/**
* Class Ckeditor
* @package skeeks\cms\widgets\formInputs\ckeditor
*/
class Ckeditor extends CKEditorWidget
{
/**
* @var Модель к которой привязываются файлы
*/
public $relatedModel;
public function __construct($config = [])
{
if (\Yii::$app->admin->requestIsAdmin) {
$config = ArrayHelper::merge(\Yii::$app->admin->getCkeditorOptions(), $config);
}
parent::__construct($config);
}
public function init()
{
$additionalData = [];
/*if ($this->relatedModel && ($this->relatedModel instanceof ActiveRecord && !$this->relatedModel->isNewRecord)) {
$additionalData = [
'className' => $this->relatedModel->className(),
'pk' => $this->relatedModel->primaryKey,
];
}*/
$url = BackendUrlHelper::createByParams(['/cms/admin-storage-files'])
->enableEmptyLayout()
->setCallbackEventName("ckeditor")
->url;
//$this->clientOptions['filebrowserImageUploadUrl'] = $url;
$this->clientOptions['filebrowserImageBrowseUrl'] = $url;
$this->clientOptions['filebrowserBrowseUrl'] = $url;
/*$this->clientOptions['filebrowserImageUploadUrl'] = \skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(['/cms/admin-tools/select-file'])
->merge($additionalData)
->enableEmptyLayout()
->url;
$this->clientOptions['filebrowserImageBrowseUrl'] = \skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(['/cms/admin-tools/select-file'])
->merge($additionalData)
->enableEmptyLayout()
->url;
$this->clientOptions['filebrowserBrowseUrl'] = \skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(['/cms/admin-tools/select-file'])
->merge($additionalData)
->enableEmptyLayout()
->url;*/
parent::init();
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/ckeditor/Asset.php | src/widgets/formInputs/ckeditor/Asset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 16.10.2014
* @since 1.0.0
*/
namespace skeeks\cms\widgets\formInputs\ckeditor;
use yii\web\AssetBundle;
/**
* Class AppAsset
* @package backend\assets
*/
class Asset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/formInputs/ckeditor/assets';
public $css = [];
public $js = [
'imageselect.png'
];
public $depends = [];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/views/smart-duration.php | src/widgets/formInputs/views/smart-duration.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 02.03.2016
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\formInputs\SmartTimeInputWidget */
$widget = $this->context;
$model = $widget->model;
$this->registerCss(<<<CSS
.sx-smart-time-wrapper {
padding-top: 3px;
padding-bottom: 3px;
}
CSS
);
?>
<?= \yii\helpers\Html::beginTag('div', $widget->wrapperOptions); ?>
<div style="display: none;">
<div class="sx-real">
<?= $element; ?>
</div>
</div>
<div class="sx-not-real">
<div class="input-group">
<input class="form-control" type="number" step="1" style="max-width: 200px;">
<?= \yii\helpers\Html::listBox("sx-not-real-select", "sec", [
'sec' => 'сек',
'min' => 'мин',
'hour' => 'час',
//'dday' => 'дней',
], ['size' => 1, 'class' => 'form-control', 'style' => 'max-width: 70px;']) ?>
</div>
</div>
<?
$jsOptions = \yii\helpers\Json::encode($widget->clientOptions);
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.SmartTimeWidget = sx.classes.Component.extend({
_onDomReady: function()
{
var self = this;
this.getNotRealInput().on("keyup change", function() {
var notRalVal = self.getNotRealInput().val();
var measure = self.getNotRealSelect().val();
var realValue = 0;
if (measure == 'min') {
realValue = notRalVal * 60;
} else if (measure == 'hour') {
realValue = notRalVal * 3600;
} else {
realValue = notRalVal
}
self.getRealInput().val(realValue);
});
this.getNotRealSelect().on("change", function() {
var notRalVal = self.getNotRealInput().val();
var measure = self.getNotRealSelect().val();
var realValue = 0;
if (measure == 'min') {
realValue = notRalVal * 60;
self.getNotRealInput().attr("step", "0.01");
} else if (measure == 'hour') {
realValue = notRalVal * 3600 ;
self.getNotRealInput().attr("step", "0.0001");
} else {
self.getNotRealInput().attr("step", "1");
realValue = notRalVal
}
self.getRealInput().val(realValue);
});
var startVal = this.getRealInput().val();
if (startVal == 0) {
self.getNotRealSelect().val("min");
self.getNotRealInput().attr("step", "0.01");
} else {
if (startVal >= 3600) {
var val = startVal/3600;
self.getNotRealInput().val(val);
self.getNotRealSelect().val("hour");
self.getNotRealInput().attr("step", "0.0001");
} else if (startVal >= 60) {
var val = startVal/60;
self.getNotRealInput().val(val);
self.getNotRealSelect().val("min");
self.getNotRealInput().attr("step", "0.01");
} else {
var val = startVal;
self.getNotRealInput().val(val);
self.getNotRealSelect().val("sec");
self.getNotRealInput().attr("step", "1");
}
}
},
getRealInput: function() {
return $(".sx-real input", this.getJWrapper());
},
getNotRealInput: function() {
return $(".sx-not-real input", this.getJWrapper());
},
getNotRealSelect: function() {
return $(".sx-not-real select", this.getJWrapper());
},
getJWrapper: function() {
return $("#" + this.get('id'));
}
});
new sx.classes.SmartTimeWidget({$jsOptions});
})(sx, sx.$, sx._);
JS
); ?>
<?= \yii\helpers\Html::endTag('div'); ?> | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/views/model-storage-files.php | src/widgets/formInputs/views/model-storage-files.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.09.2015
*/
/* @var $widget \skeeks\cms\widgets\formInputs\ModelStorageFiles */
/* @var $this yii\web\View */
/* @var $model \yii\db\ActiveRecord */
if (!$widget->viewItemTemplate) {
$controller = \Yii::$app->createController('cms/admin-storage-files')[0];
}
?>
<?
$this->registerCss(<<<CSS
.sx-fromWidget-storageImages
{}
.sx-fromWidget-storageImages .sx-main-image img
{
max-width: 250px;
border: 2px solid silver;
}
.sx-fromWidget-storageImages .sx-main-image img:hover
{
border: 2px solid #20a8d8;
}
.sx-fromWidget-storageImages .sx-controlls
{
margin-top: 3px;
}
.sx-fromWidget-storageImages .sx-image
{
float: left;
margin-right: 15px;
margin-bottom: 15px;
box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.42);
padding: 10px;
background: white;
}
.sx-fromWidget-storageImages .sx-group-images img
{
max-width: 100px;
border: 1px solid silver;
margin-bottom: 5px;
}
.sx-fromWidget-storageImages .sx-group-images img:hover
{
max-width: 100px;
border: 1px solid #20a8d8;
}
CSS
);
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.MultiUpload = sx.classes.Component.extend({
execute: function()
{
var ajaxQuery = sx.ajax.preparePostQuery(this.get('backendUrl'), this.toArray());
new sx.classes.AjaxHandlerStandartRespose(ajaxQuery);
ajaxQuery.execute();
}
});
})(sx, sx.$, sx._);
JS
);
?>
<div class="sx-fromWidget-storageImages">
<?php \skeeks\cms\modules\admin\widgets\Pjax::begin([
'id' => 'pjax-storage-images-widget-' . $widget->id,
'blockPjaxContainer' => true,
]); ?>
<div class="sx-group-images">
<div class="row col-md-12">
<?php if ($files = $widget->files) : ?>
<?php foreach ($files as $imageFile) : ?>
<?php if ($imageFile instanceof \skeeks\cms\models\StorageFile) : ?>
<div class="sx-image">
<?php if (!$widget->viewItemTemplate) : ?>
<?php if ($imageFile->isImage()) : ?>
<a href="<?= $imageFile->src; ?>" class="sx-fancybox" data-pjax="0">
<img src="<?= \Yii::$app->imaging->getImagingUrl($imageFile->src,
new \skeeks\cms\components\imaging\filters\Thumbnail()); ?>"/>
</a>
<?php else
: ?>
<?= $imageFile->name ? $imageFile->name : $imageFile->original_name;
?>
<?php endif; ?>
<div class="sx-controlls">
<?
try {
$controllerTmp = clone $controller;
$controllerTmp->setModel($imageFile);
echo \skeeks\cms\backend\widgets\DropdownControllerActionsWidget::widget([
"actions" => $controllerTmp->modelActions,
"isOpenNewWindow" => true,
"clientOptions" =>
[
'pjax-id' => 'pjax-storage-images-widget-' . $widget->id
],
]);
} catch (\Exception $e) {
echo $e->getMessage();
}
?>
</div>
<?php else
: ?>
<?= $widget->renderItem($imageFile);
?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<?php \skeeks\cms\modules\admin\widgets\Pjax::end(); ?>
<div class="sx-controlls">
<?= \skeeks\cms\widgets\StorageFileManager::widget(\yii\helpers\ArrayHelper::merge([
'clientOptions' =>
[
'simpleUpload' =>
[
'options' =>
[
'multiple' => true
]
],
'completeUploadFile' => new \yii\web\JsExpression(<<<JS
function(data)
{
var result = data.response;
if (result.success === true)
{
var SingleUpload = new sx.classes.MultiUpload( _.extend({$widget->getJsonString()}, {
'file_id' : result.file.id,
}) );
SingleUpload.execute();
}
$.pjax.reload('#pjax-storage-images-widget-{$widget->id}', {});
}
JS
)
],
], $widget->controllWidgetOptions)); ?>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/views/storage-image.php | src/widgets/formInputs/views/storage-image.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.09.2015
*/
/* @var $widget \skeeks\cms\widgets\formInputs\StorageImage */
/* @var $this yii\web\View */
/* @var $model \yii\db\ActiveRecord */
$controller = \Yii::$app->createController('cms/admin-storage-files')[0];
?>
<?
$this->registerCss(<<<CSS
.sx-fromWidget-storageImages
{}
.sx-fromWidget-storageImages .sx-main-image img
{
max-width: 250px;
border: 2px solid silver;
}
.sx-fromWidget-storageImages .sx-main-image img:hover
{
border: 2px solid #20a8d8;
}
.sx-fromWidget-storageImages .sx-controlls
{
margin-top: 3px;
}
.sx-fromWidget-storageImages .sx-image
{
float: left;
margin-right: 15px;
margin-bottom: 15px;
box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.42);
padding: 10px;
background: white;
}
.sx-fromWidget-storageImages .sx-group-images img
{
max-width: 100px;
border: 1px solid silver;
margin-bottom: 5px;
}
.sx-fromWidget-storageImages .sx-group-images img:hover
{
max-width: 100px;
border: 1px solid #20a8d8;
}
CSS
);
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.SingleUpload = sx.classes.Component.extend({
execute: function()
{
var ajaxQuery = sx.ajax.preparePostQuery(this.get('backendUrl'), this.toArray());
new sx.classes.AjaxHandlerStandartRespose(ajaxQuery);
ajaxQuery.execute();
}
});
})(sx, sx.$, sx._);
JS
);
?>
<div class="sx-fromWidget-storageImages">
<?php \skeeks\cms\modules\admin\widgets\Pjax::begin([
'id' => 'pjax-storage-images-widget-' . $widget->id,
'blockPjaxContainer' => true,
]); ?>
<div class="sx-group-images">
<div class="row col-md-12">
<?php if ($imageFile = $widget->image) : ?>
<div class="sx-image">
<?php if (!$widget->viewItemTemplate) : ?>
<a href="<?= $imageFile->src; ?>" class="sx-fancybox" data-pjax="0">
<img src="<?= \Yii::$app->imaging->getImagingUrl($imageFile->src,
new \skeeks\cms\components\imaging\filters\Thumbnail()); ?>"/>
</a>
<div class="sx-controlls">
<?
$controllerTmp = clone $controller;
$controllerTmp->setModel($imageFile);
echo \skeeks\cms\backend\widgets\DropdownControllerActionsWidget::widget([
"actions" => $controllerTmp->modelActions,
"isOpenNewWindow" => true,
"clientOptions" =>
[
'pjax-id' => 'pjax-storage-images-widget-' . $widget->id
],
]);
?>
</div>
<?php else
: ?>
<?= $widget->renderItem($imageFile);
?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php \skeeks\cms\modules\admin\widgets\Pjax::end(); ?>
<div class="sx-controlls">
<?= \skeeks\cms\widgets\StorageFileManager::widget([
'clientOptions' =>
[
'simpleUpload' =>
[
'options' =>
[
'multiple' => true
]
],
'completeUploadFile' => new \yii\web\JsExpression(<<<JS
function(data)
{
var result = data.response;
if (result.success === true)
{
var SingleUpload = new sx.classes.SingleUpload( _.extend({$widget->getJsonString()}, {
'file_id' : result.file.id,
}) );
SingleUpload.execute();
}
$.pjax.reload('#pjax-storage-images-widget-{$widget->id}', {});
}
JS
)
],
]); ?>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/componentSettings/ComponentSettingsWidgetAsset.php | src/widgets/formInputs/componentSettings/ComponentSettingsWidgetAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
namespace skeeks\cms\widgets\formInputs\componentSettings;
use Yii;
use yii\web\AssetBundle;
/**
* Class ComponentSettingsWidgetAsset
* @package skeeks\cms\widgets\formInputs\componentSettings
*/
class ComponentSettingsWidgetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/formInputs/componentSettings/assets';
public $css = [];
public $js =
[
'component-settings.js',
];
public $depends = [
'\skeeks\sx\assets\Core',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/componentSettings/ComponentSettingsWidget.php | src/widgets/formInputs/componentSettings/ComponentSettingsWidget.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 09.06.2015
*/
namespace skeeks\cms\widgets\formInputs\componentSettings;
use skeeks\cms\Exception;
use skeeks\cms\helpers\StringHelper;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\modules\admin\Module;
use skeeks\widget\codemirror\CodemirrorWidget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
use Yii;
/**
* Class ComponentSettingsWidget
* @package skeeks\cms\widgets\formInputs\componentSettings
*/
class ComponentSettingsWidget extends InputWidget
{
/**
* @var array Общие js опции текущего виджета
*/
public $clientOptions = [];
/**
* @var string ID селекта компонентов
*/
public $componentSelectId = "";
public $buttonText = "";
public $buttonClasses = "sx-btn-edit btn btn-xs btn-default";
public function init()
{
parent::init();
if (!$this->buttonText) {
$this->buttonText = \Yii::t('skeeks/cms', 'Setting property');
}
}
/**
* @inheritdoc
*/
public function run()
{
if ($this->hasModel()) {
$name = Html::getInputName($this->model, $this->attribute);
$value = null;
if (is_array($this->model->{$this->attribute})) {
$value = StringHelper::base64EncodeUrl(serialize((array)$this->model->{$this->attribute}));
} else {
if (is_string($this->model->{$this->attribute})) {
$value = $this->model->{$this->attribute};
}
}
$this->options['id'] = Html::getInputId($this->model, $this->attribute);
//$element = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
$element = Html::hiddenInput($name, $value, $this->options);
} else {
$element = Html::hiddenInput($this->name, $this->value, $this->options);
}
$this->registerPlugin();
$this->clientOptions['componentSelectId'] = $this->componentSelectId;
$this->clientOptions['componentSettingsId'] = Html::getInputId($this->model, $this->attribute);
$this->clientOptions['id'] = $this->id;
$this->clientOptions['backend'] = \skeeks\cms\backend\helpers\BackendUrlHelper::createByParams(['/cms/admin-universal-component-settings/index'])
->enableEmptyLayout()
->url;
return $this->render('element', [
'widget' => $this,
'element' => $element
]);
}
/**
* Registers CKEditor plugin
*/
protected function registerPlugin()
{
ComponentSettingsWidgetAsset::register($this->view);
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/formInputs/componentSettings/views/element.php | src/widgets/formInputs/componentSettings/views/element.php | <?
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.06.2015
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\formInputs\componentSettings\ComponentSettingsWidget */
/* @var $element string */
$options = $widget->clientOptions;
$clientOptions = \yii\helpers\Json::encode($options);
?>
<div id="<?= $widget->id; ?>">
<div class="sx-select-controll">
<?= $element; ?>
</div>
<a href="#" class="<?= $widget->buttonClasses; ?>">
<i class="fa fa-cog"></i> <?= $widget->buttonText; ?>
</a>
</div>
<?
$this->registerJs(<<<JS
(function(sx, $, _)
{
new sx.classes.ComponentSettingsWidget({$clientOptions});
})(sx, sx.$, sx._);
JS
)
?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/views/dual-select.php | src/widgets/views/dual-select.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link https://skeeks.com/
* @copyright (c) 2010 SkeekS
* @date 24.03.2018
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\DualSelect */
/* @var $element string */
$widget = $this->context;
\yii\jui\Sortable::widget();
$hidden = $widget->items;
$visible = [];
$values = (array) $widget->model->{$widget->attribute};
foreach ($values as $value)
{
if ($value) {
$visible[$value] = \yii\helpers\ArrayHelper::getValue($hidden, $value);
\yii\helpers\ArrayHelper::remove($hidden, $value);
}
}
\skeeks\cms\widgets\assets\DualSelectAsset::register($this);
\yii\jui\Sortable::widget();
$js = \yii\helpers\Json::encode($widget->jsOptions);
$this->registerJs(<<<JS
(function(sx, $, _)
{
new sx.classes.DualSelect({$js});
})(sx, sx.$, sx._);
JS
);
?>
<?= \yii\helpers\Html::beginTag('div', $widget->wrapperOptions); ?>
<div style="display: none;"><?= $element; ?></div>
<div class="row">
<div class="col-sm-4 col-sm-offset-1">
<?= $widget->renderHtml($widget->hiddenLabel); ?>
<ul class="sx-sortable-hidden sx-sortable-list cursor-move <?= $widget->id; ?>-conncected">
<? if ($hidden): ?>
<? foreach ($hidden as $value => $label) : ?>
<?= $widget->renderItem($value, $label); ?>
<? endforeach; ?>
<? endif; ?>
</ul>
</div>
<div class="col-sm-2 text-center">
<div class="sx-dual-select-separator">
<i class="glyphicon glyphicon-resize-horizontal"></i>
</div>
</div>
<div class="col-sm-4">
<?= $widget->renderHtml($widget->visibleLabel); ?>
<ul class="sx-sortable-visible sx-sortable-list cursor-move <?= $widget->id; ?>-conncected">
<? foreach ($visible as $value => $label) : ?>
<?= $widget->renderItem($value, $label); ?>
<? endforeach; ?>
</ul>
</div>
</div>
<?= \yii\helpers\Html::endTag('div'); ?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/views/filters.php | src/widgets/views/filters.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link https://skeeks.com/
* @copyright (c) 2010 SkeekS
* @date 18.03.2018
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\FiltersWidget */
$widget = $this->context;
$fields = $widget->filtersModel->builderFields();
?>
<?
$activeFormClassName = \yii\helpers\ArrayHelper::getValue($widget->activeForm, 'class', \yii\widgets\ActiveForm::class);
\yii\helpers\ArrayHelper::remove($widget->activeForm, 'class');
$form = $activeFormClassName::begin((array)$widget->activeForm);
echo (new \skeeks\yii2\form\Builder([
'models' => $widget->filtersModel->builderModels(),
'model' => $widget->filtersModel,
'activeForm' => $form,
'fields' => $fields,
]))->render();
?>
<div class="row sx-form-buttons">
<div class="col-sm-12">
<div class="col-sm-3""></div>
<div class="col-sm-6">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-filter"></i> Применить</button>
</div>
<div class="col-sm-3">
</div>
</div>
</div>
<?
$activeFormClassName::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/widgets/views/sort-select.php | src/widgets/views/sort-select.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link https://skeeks.com/
* @copyright (c) 2010 SkeekS
* @date 24.03.2018
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\SortSelect */
/* @var $element string */
$widget = $this->context;
\yii\jui\Sortable::widget();
$hidden = $widget->items;
$visible = [];
$values = (array) $widget->model->{$widget->attribute};
\yii\jui\Sortable::widget();
$js = \yii\helpers\Json::encode($widget->jsOptions);
$this->registerJs(<<<JS
(function(sx, $, _)
{
//new sx.classes.DualSelect({$js});
})(sx, sx.$, sx._);
JS
);
?>
<?= \yii\helpers\Html::beginTag('div', $widget->wrapperOptions); ?>
<div style="display: none;"><?= $element; ?></div>
<div class="row">
<? $counter = 0; ?>
<? foreach ($values as $key => $value) : ?>
<div class="col-sm-4 col-sm-offset-1">
<?= \yii\helpers\Html::listBox(\yii\helpers\Html::getInputName($widget->model, $widget->attribute) . "[{$counter}]", $key, $widget->items, [
'class' => 'form-control',
'size' => 1
]); ?>
</div>
<div class="col-sm-4 col-sm-offset-1">
<?= \yii\helpers\Html::listBox(\yii\helpers\Html::getInputName($widget->model, $widget->attribute) . "[{$counter}]", $value, [
SORT_ASC => "asc",
SORT_DESC => "desc",
], [
'class' => 'form-control',
'size' => 1
]); ?>
</div>
<? $counter ++; ?>
<? endforeach; ?>
</div>
<?= \yii\helpers\Html::endTag('div'); ?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/assets/FieldSetAsset.php | src/widgets/assets/FieldSetAsset.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\widgets\assets;
use skeeks\cms\base\AssetBundle;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class FieldSetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/assets/src/field-set';
public $css = [
'field-set.css',
];
public $js = [
'url.min.js',
'field-set.js',
];
public $depends = [
'yii\web\YiiAsset',
'skeeks\sx\assets\Custom',
];
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/assets/GridViewAsset.php | src/widgets/assets/GridViewAsset.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\widgets\assets;
use skeeks\cms\base\AssetBundle;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class GridViewAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/assets/src/grid-view';
public $css = [
'grid.css',
];
public $js = [];
public $depends = [
'yii\web\YiiAsset',
'skeeks\sx\assets\Custom',
];
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/assets/DualSelectAsset.php | src/widgets/assets/DualSelectAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\widgets\assets;
use skeeks\cms\base\AssetBundle;
/**
* Class DualSelectAsset
* @package skeeks\cms\assets
*/
class DualSelectAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/assets/src/dual-select';
public $css = [
'dual-select.css'
];
public $js = [
'dual-select.js',
];
public $depends = [
'skeeks\sx\assets\Custom',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/tree/CmsTreeWidget.php | src/widgets/tree/CmsTreeWidget.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.12.2016
*/
namespace skeeks\cms\widgets\tree;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\models\CmsSite;
use skeeks\cms\models\CmsTree;
use skeeks\cms\widgets\tree\assets\CmsTreeWidgetAsset;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\helpers\Url;
/**
* @property string $searchValue
* @property int[] $openedIds
*
* Class CmsTreeWidget
* @package skeeks\cms\widgets\tree
*/
class CmsTreeWidget extends Widget
{
public static $autoIdPrefix = 'cmsTreeWidget';
/**
* @var array Widget wrapper options
*/
public $options = [];
/**
* @var array Nodes for which to build a tree.
*/
public $models = [];
/**
* @var string Widget session param name
*/
public $sessionName = "cms-tree-opened-v2";
/**
* @var string
*/
public $openedRequestName = "o";
/**
* @var string
*/
public $searchRequestName = "__sx-tree-search";
/**
* @var bool
*/
public $isSearchEnabled = true;
/**
* @var string Widget view file
*/
public $viewFile = 'tree';
/**
* @var string Widget one node view file
*/
public $viewNodeFile = '_node';
/**
* @var string Inner node content file
*/
public $viewNodeContentFile = '_node-content';
/**
* @var array Additional information in the context of a call widget
*/
public $contextData = [];
/**
* @var \yii\widgets\Pjax
*/
public $pjax = null;
public $pjaxClass = 'skeeks\cms\widgets\Pjax';
public $pjaxOptions = [
'isBlock' => true
];
protected $_pjaxIsStart = false;
public function init()
{
parent::init();
$this->options['id'] = $this->id;
Html::addCssClass($this->options, 'sx-tree');
//Automatic filling models
if ($this->models !== false && is_array($this->models) && count($this->models) == 0) {
$this->models = CmsTree::findRoots()
->cmsSite()
->joinWith('cmsSiteRelation')
->orderBy([CmsSite::tableName() . ".priority" => SORT_ASC])->all();
}
$this->_beginPjax();
}
/**
* @return array
*/
public function getSearchValue()
{
if (\Yii::$app->request->getQueryParam($this->searchRequestName, false) === false) {
$fromRequest = \Yii::$app->getSession()->get($this->searchRequestName, "");
} else {
$fromRequest = \skeeks\cms\helpers\StringHelper::strtolower((string) \Yii::$app->request->getQueryParam($this->searchRequestName));
\Yii::$app->getSession()->set($this->searchRequestName, $fromRequest);
}
return $fromRequest;
}
/**
* @return array
*/
public function getOpenedIds()
{
$opened = [];
if ($fromRequest = \Yii::$app->request->getQueryParam($this->openedRequestName)) {
if (is_string($fromRequest)) {
$fromRequest = explode("_", $fromRequest);
}
$opened = array_unique($fromRequest);
if ($this->sessionName) {
\Yii::$app->getSession()->set($this->sessionName, $opened);
}
} else {
if ($this->sessionName) {
$opened = array_unique(\Yii::$app->getSession()->get($this->sessionName, []));
}
}
return $opened;
}
/**
* @return string
*/
public function run()
{
$this->registerAssets();
echo $this->render($this->viewFile);
$this->_endPjax();
}
/**
* @return $this
*/
protected function _beginPjax()
{
if (!$this->pjax) {
$pjaxClass = $this->pjaxClass;
$pjaxOptions = ArrayHelper::merge($this->pjaxOptions, [
'id' => 'sx-pjax-' . $this->id,
//'enablePushState' => false,
]);
$this->_pjaxIsStart = true;
$this->pjax = $pjaxClass::begin($pjaxOptions);
}
return $this;
}
/**
* @return $this
*/
protected function _endPjax()
{
if ($this->_pjaxIsStart === true) {
$className = $this->pjax->className();
$className::end();
}
return $this;
}
/**
* @param $models
* @return string
*/
public function renderNodes($models)
{
$options["item"] = [$this, 'renderNode'];
$ul = Html::ul($models, $options);
return $ul;
}
/**
* @param $model
* @return string
*/
public function renderNode($model)
{
return $this->render($this->viewNodeFile, [
'model' => $model,
]);
}
/**
* @param $model
* @return string
*/
public function renderNodeContent($model)
{
return $this->render($this->viewNodeContentFile, [
'model' => $model,
]);
}
/**
* @param $model
* @return $this|string
*/
public function getOpenCloseLink($model)
{
$currentLink = "";
if ($model->children) {
$openedIds = $this->openedIds;
if ($this->isOpenNode($model)) {
$newOptionsOpen = [];
foreach ($openedIds as $id) {
if ($id != $model->id) {
$newOptionsOpen[] = $id;
}
}
$urlOptionsOpen = array_unique($newOptionsOpen);
$params = \Yii::$app->request->getQueryParams();
$pathInfo = \Yii::$app->request->pathInfo;
//$params[$this->openedRequestName] = $urlOptionsOpen;
$params[$this->openedRequestName] = implode("_", $urlOptionsOpen);
$currentLink = "/{$pathInfo}?" . http_build_query($params);
} else {
$urlOptionsOpen = array_unique(array_merge($openedIds, [$model->id]));
$params = \Yii::$app->request->getQueryParams();
//$params[$this->openedRequestName] = $urlOptionsOpen;
$params[$this->openedRequestName] = implode("_", $urlOptionsOpen);
$pathInfo = \Yii::$app->request->pathInfo;
$currentLink = "/{$pathInfo}?" . http_build_query($params);
}
}
return $currentLink;
}
/**
* Нода для этой модели открыта?
*
* @param $model
* @return bool
*/
public function isOpenNode($model)
{
if ($this->searchValue) {
return true;
}
$isOpen = false;
if ($openedIds = (array)$this->openedIds) {
if (in_array($model->id, $openedIds)) {
$isOpen = true;
}
}
return $isOpen;
}
/**
*
*
* @param $model
* @return string
*/
public function getNodeName($model)
{
/**
* @var $model \skeeks\cms\models\Tree
*/
$result = $model->name;
$additionalName = '';
if ($model->level == 0) {
$site = CmsSite::findOne(['id' => $model->cms_site_id]);
if ($site) {
$additionalName = $site->name;
}
} else {
if ($model->name_hidden) {
$additionalName = $model->name_hidden;
}
}
if ($additionalName) {
$result .= " [{$additionalName}]";
}
return $result;
}
public function registerAssets()
{
$options = Json::encode([
'id' => $this->id,
'pjaxid' => $this->pjax->id
]);
CmsTreeWidgetAsset::register($this->getView());
$this->getView()->registerJs(<<<JS
(function(window, sx, $, _)
{
sx.createNamespace('classes.tree', sx);
sx.classes.tree.CmsTreeWidget = sx.classes.Component.extend({
_init: function()
{
var self = this;
},
_onDomReady: function()
{
var self = this;
},
});
new sx.classes.tree.CmsTreeWidget({$options});
})(window, sx, sx.$, sx._);
JS
);
$this->getView()->registerCss(<<<CSS
CSS
);
}
} | php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/tree/views/_node.php | src/widgets/tree/views/_node.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 18.12.2016
*/
/**
* @var $this yii\web\View
* @var $widget \skeeks\cms\widgets\tree\CmsTreeWidget
* @var $model \skeeks\cms\models\CmsTree
*/
$widget = $this->context;
?>
<?php /*if($widget->searchValue) : */?><!--
<?/* if (in_array($model->id, \yii\helpers\ArrayHelper::map($widget->models, 'id', 'id'))) : */?>
<?/* if ($childs = $model->getDescendants()->andWhere(['like', 'name', $widget->searchValue])->all()) : */?>
<?/* foreach ($childs as $child) : */?>
<?/*= \yii\helpers\Html::beginTag('li', [
"class" => "sx-tree-node sx-tree-node-{$child->id} " . ($widget->isOpenNode($child) ? " open" : ""),
"data-id" => $child->id,
"title" => ""
]); */?>
<div class="row">
<?/*= $widget->renderNodeContent($child); */?>
</div>
<?/*= \yii\helpers\Html::endTag('li'); */?>
<?/* endforeach; */?>
<?/* endif; */?>
<?/* endif; */?>
--><?php /*else : */?>
<?= \yii\helpers\Html::beginTag('li', [
"class" => "sx-tree-node sx-tree-node-{$model->id} " . ($widget->isOpenNode($model) ? " open" : ""),
"data-id" => $model->id,
"title" => ""
]); ?>
<? if ($widget->searchValue) : ?>
<?
$isShowChilds = $model->getDescendants()->andWhere(['like', 'name', $widget->searchValue])->exists();
$isExistChildren = $model->getChildren()->exists();
$isShowCurrent = (strpos(\skeeks\cms\helpers\StringHelper::strtolower($model->name), (string) $widget->searchValue) !== false);
?>
<? if ($isShowCurrent || $isShowChilds) : ?>
<div class="row">
<?php if ($isExistChildren) : ?>
<div class="sx-node-open-close">
<?php if ($widget->isOpenNode($model)) : ?>
<a href="<?= $widget->getOpenCloseLink($model); ?>" class="btn btn-sm btn-default">
<span class="fa fa-minus" title="<?= \Yii::t('skeeks/cms', "Minimize"); ?>"></span>
</a>
<?php else
: ?>
<a href="<?= $widget->getOpenCloseLink($model);
?>" class="btn btn-sm btn-default">
<span class="fa fa-plus" title="<?= \Yii::t('skeeks/cms', "Restore"); ?>"></span>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
<?= $widget->renderNodeContent($model); ?>
</div>
<? if ($isShowChilds) : ?>
<!-- Construction of child elements -->
<?php if ($widget->isOpenNode($model) && $model->children) : ?>
<?= $widget->renderNodes($model->children); ?>
<?php endif; ?>
<? elseif ($isExistChildren) : ?>
Есть еще подразделы...
<? endif; ?>
<? endif; ?>
<? else : ?>
<div class="row">
<?php if ($model->children) : ?>
<div class="sx-node-open-close">
<?php if ($widget->isOpenNode($model)) : ?>
<a href="<?= $widget->getOpenCloseLink($model); ?>" class="btn btn-sm btn-default">
<span class="fa fa-minus" title="<?= \Yii::t('skeeks/cms', "Minimize"); ?>"></span>
</a>
<?php else
: ?>
<a href="<?= $widget->getOpenCloseLink($model);
?>" class="btn btn-sm btn-default">
<span class="fa fa-plus" title="<?= \Yii::t('skeeks/cms', "Restore"); ?>"></span>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
<?= $widget->renderNodeContent($model); ?>
</div>
<!-- Construction of child elements -->
<?php if ($widget->isOpenNode($model) && $model->children) : ?>
<?= $widget->renderNodes($model->children); ?>
<?php endif; ?>
<? endif; ?>
<?= \yii\helpers\Html::endTag('li'); ?>
<?php /*endif; */?>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/tree/views/_node-content.php | src/widgets/tree/views/_node-content.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 18.12.2016
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\tree\CmsTreeWidget */
/* @var $model \skeeks\cms\models\CmsTree */
$widget = $this->context;
?>
<div class="sx-label-node level-<?= $model->level; ?> status-<?= $model->active; ?>">
<a href="<?= $widget->getOpenCloseLink($model); ?>">
<?= $model->name; ?>
</a>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/tree/views/tree.php | src/widgets/tree/views/tree.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 18.12.2016
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\tree\CmsTreeWidget */
$widget = $this->context;
$params = \Yii::$app->request->getQueryParams();
$this->registerJs(<<<JS
$(".sx-tree-search input").on("change", function() {
console.log("change");
var jTreeSearch = $(this).closest(".sx-tree-search");
$(".btn-search", jTreeSearch).click();
});
$(".sx-tree-search .btn").on("click", function() {
var jTreeSearch = $(this).closest(".sx-tree-search");
var search = $("input", jTreeSearch).val();
var jPjax = $(this).closest("[data-pjax-container]");
var url = new URL(window.location.href);
url.searchParams.set($("input", jTreeSearch).attr("name"), search);
/*var urlParams = new URLSearchParams(window.location.search);
urlParams.set($("input", jTreeSearch).attr("name"), search);
window.location.search = urlParams;*/
$.pjax({url: url.pathname + url.search, container: '#' + jPjax.attr("id")});
return false;
});
JS
);
?>
<div class="row">
<div class="sx-container-tree">
<?= \yii\helpers\Html::beginTag("div", $widget->options); ?>
<? if ($widget->isSearchEnabled) : ?>
<div class="sx-tree-search" style="max-width: 300px; margin-bottom: 10px;">
<input type="text" value="<?php echo $widget->searchValue; ?>" name="<?php echo $widget->searchRequestName; ?>" class="form-control" placeholder="Поиск по разделам"/>
<button class="btn btn-search">
<i class="fas fa-search"></i>
</button>
</div>
<? endif; ?>
<div class="cms-tree-wrapper">
<?= $widget->renderNodes($widget->models); ?>
</div>
<?= \yii\helpers\Html::endTag("div"); ?>
</div>
</div>
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/widgets/tree/assets/CmsTreeWidgetAsset.php | src/widgets/tree/assets/CmsTreeWidgetAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 19.12.2016
*/
namespace skeeks\cms\widgets\tree\assets;
use yii\web\AssetBundle;
/**
* Class AppAsset
* @package skeeks\cms\modules\admin
*/
class CmsTreeWidgetAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/widgets/tree/assets/src';
public $css = [
'css/style.css',
];
public $js = [
];
public $depends = [
'skeeks\sx\assets\Core',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/ActiveFormAjaxSubmitAsset.php | src/assets/ActiveFormAjaxSubmitAsset.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\assets;
use skeeks\cms\base\AssetBundle;
/**
* @author Semenov Alexander <semenov@skeeks.com>
*/
class ActiveFormAjaxSubmitAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/assets/src';
public $css = [
];
public $js = [
'classes/active-form/AjaxSubmit.js',
];
public $depends = [
'\skeeks\sx\assets\Custom',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/FancyboxAssets.php | src/assets/FancyboxAssets.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\assets;
use skeeks\cms\base\AssetBundle;
use yii\web\YiiAsset;
/**
* Class AppAsset
* @package backend\assets
*/
class FancyboxAssets extends AssetBundle
{
public $sourcePath = '@skeeks/cms/assets/src/fancybox';
public $js = [
'jquery.fancybox.min.js',
];
public $css = [
'jquery.fancybox.min.css',
];
/*public $depends = [
YiiAsset::class
];*/
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/FancyboxThumbsAssets.php | src/assets/FancyboxThumbsAssets.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\assets;
/**
* Class AppAsset
* @package backend\assets
*/
class FancyboxThumbsAssets extends FancyboxAssets
{
public $js = [
'helpers/jquery.fancybox-thumbs.js',
];
public $css = [
'helpers/jquery.fancybox-thumbs.css',
];
public $depends = [
'\skeeks\cms\assets\FancyboxAssets',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/LinkActvationAsset.php | src/assets/LinkActvationAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\assets;
use skeeks\cms\base\AssetBundle;
/**
*
* example:
\skeeks\cms\assets\LinkActvationAsset::register($this);
$this->registerJs(<<<JS
new sx.classes.LinkActivation('.sx-task-description');
JS
);
*
*
* Class CmsAsset
* @package skeeks\cms\assets
*/
class LinkActvationAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/assets/src/link-activation';
public $css = [
];
public $js = [
'link-activation.js',
];
public $depends = [
'\skeeks\sx\assets\Custom',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/CmsAsset.php | src/assets/CmsAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\assets;
use skeeks\cms\base\AssetBundle;
/**
* Class CmsAsset
* @package skeeks\cms\assets
*/
class CmsAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/assets/src';
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/AdultAsset.php | src/assets/AdultAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\assets;
use skeeks\cms\base\AssetBundle;
/**
* Class CmsAsset
* @package skeeks\cms\assets
*/
class AdultAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/assets/src/adult';
public $css = [
'adult.css',
];
public $js = [
'adult.js',
];
public $depends = [
'\skeeks\sx\assets\Custom',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/assets/JsTaskManagerAsset.php | src/assets/JsTaskManagerAsset.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 15.03.2015
*/
namespace skeeks\cms\assets;
use skeeks\cms\base\AssetBundle;
/**
* Class JsTaskManagerAsset
* @package skeeks\cms\assets
*/
class JsTaskManagerAsset extends AssetBundle
{
public $sourcePath = '@skeeks/cms/assets/src';
public $css = [
];
public $js = [
'classes/tasks/Task.js',
'classes/tasks/AjaxTask.js',
'classes/tasks/ProgressBar.js',
'classes/tasks/Manager.js',
];
public $depends = [
'\skeeks\sx\assets\Custom',
];
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
skeeks-cms/cms | https://github.com/skeeks-cms/cms/blob/c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf/src/filters/CmsAccessControl.php | src/filters/CmsAccessControl.php | <?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 06.10.2015
*/
namespace skeeks\cms\filters;
use skeeks\cms\helpers\RequestResponse;
use skeeks\cms\helpers\UrlHelper;
use yii\helpers\Url;
use yii\web\ForbiddenHttpException;
use yii\web\User;
/**
* Class AdminAccessControl
* @package skeeks\cms\modules\admin\filters
*/
class CmsAccessControl extends \yii\filters\AccessControl
{
/**
* Denies the access of the user.
* The default implementation will redirect the user to the login page if he is a guest;
* if the user is already logged, a 403 HTTP exception will be thrown.
* @param User $user the current user
* @throws ForbiddenHttpException if the user is already logged in.
*/
protected function denyAccess($user)
{
$rr = new RequestResponse();
if ($user->getIsGuest()) {
$authUrl = UrlHelper::construct(["/cms/auth/login"])->setCurrentRef()->createAbsoluteUrl();
if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
\Yii::$app->getResponse()->redirect($authUrl);
$rr->redirect = $authUrl;
return (array)$rr;
} else {
\Yii::$app->response->redirect($authUrl);
\Yii::$app->end();
}
} else {
throw new ForbiddenHttpException(\Yii::t('yii', 'You are not allowed to perform this action.'));
}
}
}
| php | BSD-3-Clause | c22dc84c6fc4da5f67815a3339bc10c6c4aa39cf | 2026-01-05T04:50:22.405425Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.