Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • alpha
  • beta
  • develop
  • docs/fix-readme
  • docs/update-vitepress
  • draft/rss-feed
  • feat/dashboard
  • feat/episodes-page-ux
  • feat/generator-user-agent
  • feat/headliner
  • feat/new-languages
  • feat/plugins
  • fix/federation
  • fix/forms-ux
  • i18n
  • main
  • next
  • refactor/transcripts
  • v1.0.0
  • v1.0.0-alpha.1
  • v1.0.0-alpha.10
  • v1.0.0-alpha.11
  • v1.0.0-alpha.12
  • v1.0.0-alpha.13
  • v1.0.0-alpha.14
  • v1.0.0-alpha.15
  • v1.0.0-alpha.16
  • v1.0.0-alpha.17
  • v1.0.0-alpha.18
  • v1.0.0-alpha.19
  • v1.0.0-alpha.2
  • v1.0.0-alpha.20
  • v1.0.0-alpha.21
  • v1.0.0-alpha.22
  • v1.0.0-alpha.23
  • v1.0.0-alpha.24
  • v1.0.0-alpha.25
  • v1.0.0-alpha.26
  • v1.0.0-alpha.27
  • v1.0.0-alpha.28
  • v1.0.0-alpha.29
  • v1.0.0-alpha.3
  • v1.0.0-alpha.30
  • v1.0.0-alpha.31
  • v1.0.0-alpha.32
  • v1.0.0-alpha.33
  • v1.0.0-alpha.34
  • v1.0.0-alpha.35
  • v1.0.0-alpha.36
  • v1.0.0-alpha.37
  • v1.0.0-alpha.38
  • v1.0.0-alpha.39
  • v1.0.0-alpha.4
  • v1.0.0-alpha.40
  • v1.0.0-alpha.41
  • v1.0.0-alpha.42
  • v1.0.0-alpha.43
  • v1.0.0-alpha.44
  • v1.0.0-alpha.45
  • v1.0.0-alpha.46
  • v1.0.0-alpha.47
  • v1.0.0-alpha.48
  • v1.0.0-alpha.49
  • v1.0.0-alpha.5
  • v1.0.0-alpha.50
  • v1.0.0-alpha.51
  • v1.0.0-alpha.52
  • v1.0.0-alpha.53
  • v1.0.0-alpha.54
  • v1.0.0-alpha.55
  • v1.0.0-alpha.56
  • v1.0.0-alpha.57
  • v1.0.0-alpha.58
  • v1.0.0-alpha.59
  • v1.0.0-alpha.6
  • v1.0.0-alpha.60
  • v1.0.0-alpha.61
  • v1.0.0-alpha.62
  • v1.0.0-alpha.63
  • v1.0.0-alpha.64
  • v1.0.0-alpha.65
  • v1.0.0-alpha.66
  • v1.0.0-alpha.67
  • v1.0.0-alpha.68
  • v1.0.0-alpha.69
  • v1.0.0-alpha.7
  • v1.0.0-alpha.70
  • v1.0.0-alpha.71
  • v1.0.0-alpha.72
  • v1.0.0-alpha.73
  • v1.0.0-alpha.74
  • v1.0.0-alpha.75
  • v1.0.0-alpha.76
  • v1.0.0-alpha.77
  • v1.0.0-alpha.78
  • v1.0.0-alpha.79
  • v1.0.0-alpha.8
  • v1.0.0-alpha.80
  • v1.0.0-alpha.9
  • v1.0.0-beta.1
  • v1.0.0-beta.10
  • v1.0.0-beta.11
  • v1.0.0-beta.12
  • v1.0.0-beta.13
  • v1.0.0-beta.14
  • v1.0.0-beta.15
  • v1.0.0-beta.16
  • v1.0.0-beta.17
  • v1.0.0-beta.18
  • v1.0.0-beta.19
  • v1.0.0-beta.2
  • v1.0.0-beta.20
  • v1.0.0-beta.21
  • v1.0.0-beta.22
  • v1.0.0-beta.23
  • v1.0.0-beta.24
  • v1.0.0-beta.3
  • v1.0.0-beta.4
118 results

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Select Git revision
  • alpha
  • beta
  • develop
  • feat/external-chapters
  • feat/import-externals
  • feat/social-interact
  • main
  • v1.0.0-alpha.1
  • v1.0.0-alpha.10
  • v1.0.0-alpha.11
  • v1.0.0-alpha.12
  • v1.0.0-alpha.13
  • v1.0.0-alpha.14
  • v1.0.0-alpha.15
  • v1.0.0-alpha.16
  • v1.0.0-alpha.17
  • v1.0.0-alpha.18
  • v1.0.0-alpha.19
  • v1.0.0-alpha.2
  • v1.0.0-alpha.20
  • v1.0.0-alpha.21
  • v1.0.0-alpha.22
  • v1.0.0-alpha.23
  • v1.0.0-alpha.24
  • v1.0.0-alpha.25
  • v1.0.0-alpha.26
  • v1.0.0-alpha.27
  • v1.0.0-alpha.28
  • v1.0.0-alpha.29
  • v1.0.0-alpha.3
  • v1.0.0-alpha.30
  • v1.0.0-alpha.31
  • v1.0.0-alpha.32
  • v1.0.0-alpha.33
  • v1.0.0-alpha.34
  • v1.0.0-alpha.35
  • v1.0.0-alpha.36
  • v1.0.0-alpha.37
  • v1.0.0-alpha.38
  • v1.0.0-alpha.39
  • v1.0.0-alpha.4
  • v1.0.0-alpha.40
  • v1.0.0-alpha.41
  • v1.0.0-alpha.42
  • v1.0.0-alpha.43
  • v1.0.0-alpha.44
  • v1.0.0-alpha.45
  • v1.0.0-alpha.46
  • v1.0.0-alpha.47
  • v1.0.0-alpha.48
  • v1.0.0-alpha.49
  • v1.0.0-alpha.5
  • v1.0.0-alpha.50
  • v1.0.0-alpha.51
  • v1.0.0-alpha.52
  • v1.0.0-alpha.53
  • v1.0.0-alpha.54
  • v1.0.0-alpha.55
  • v1.0.0-alpha.56
  • v1.0.0-alpha.57
  • v1.0.0-alpha.58
  • v1.0.0-alpha.59
  • v1.0.0-alpha.6
  • v1.0.0-alpha.60
  • v1.0.0-alpha.61
  • v1.0.0-alpha.62
  • v1.0.0-alpha.63
  • v1.0.0-alpha.64
  • v1.0.0-alpha.65
  • v1.0.0-alpha.66
  • v1.0.0-alpha.67
  • v1.0.0-alpha.68
  • v1.0.0-alpha.69
  • v1.0.0-alpha.7
  • v1.0.0-alpha.70
  • v1.0.0-alpha.71
  • v1.0.0-alpha.72
  • v1.0.0-alpha.73
  • v1.0.0-alpha.74
  • v1.0.0-alpha.75
  • v1.0.0-alpha.76
  • v1.0.0-alpha.77
  • v1.0.0-alpha.78
  • v1.0.0-alpha.79
  • v1.0.0-alpha.8
  • v1.0.0-alpha.80
  • v1.0.0-alpha.9
  • v1.0.0-beta.1
  • v1.0.0-beta.2
  • v1.0.0-beta.3
  • v1.0.0-beta.4
  • v1.0.0-beta.5
  • v1.0.0-beta.6
  • v1.0.0-beta.7
  • v1.0.0-beta.8
95 results
Show changes
Showing
with 1769 additions and 1399 deletions
<?php
declare(strict_types=1);
/**
* Class AddCreatedByToPosts Adds created_by field to posts table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Database\Migration;
use Override;
class BaseMigration extends Migration
{
/**
* Database Connection instance
*
* @var BaseConnection
*/
protected $db;
#[Override]
public function up(): void
{
}
#[Override]
public function down(): void
{
}
}
<?php
declare(strict_types=1);
/**
* Class AppSeeder
* Calls all required seeders for castopod to work properly
* Class AppSeeder Calls all required seeders for castopod to work properly
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
......@@ -12,14 +13,14 @@
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class AppSeeder extends Seeder
{
public function run()
#[Override]
public function run(): void
{
$this->call('AuthSeeder');
$this->call('CategorySeeder');
$this->call('LanguageSeeder');
$this->call('PlatformSeeder');
}
}
<?php
/**
* Class PermissionSeeder
* Inserts permissions
*
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class AuthSeeder extends Seeder
{
protected $groups = [
[
'name' => 'superadmin',
'description' =>
'Somebody who has access to all the castopod instance features',
],
[
'name' => 'podcast_admin',
'description' =>
'Somebody who has access to all the features within a given podcast',
],
];
/** Build permissions array as a list of:
*
* ```
* context => [
* [action, description],
* [action, description],
* ...
* ]
* ```
*/
protected $permissions = [
'users' => [
[
'name' => 'create',
'description' => 'Create a user',
'has_permission' => ['superadmin'],
],
[
'name' => 'list',
'description' => 'List all users',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any user info',
'has_permission' => ['superadmin'],
],
[
'name' => 'manage_authorizations',
'description' => 'Add or remove roles/permissions to a user',
'has_permission' => ['superadmin'],
],
[
'name' => 'manage_bans',
'description' => 'Ban / unban a user',
'has_permission' => ['superadmin'],
],
[
'name' => 'force_pass_reset',
'description' =>
'Force a user to update his password upon next login',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete',
'description' =>
'Delete user without removing him from database',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete_permanently',
'description' =>
'Delete all occurrences of a user from the database',
'has_permission' => ['superadmin'],
],
],
'pages' => [
[
'name' => 'manage',
'description' => 'List / create / edit / delete pages',
'has_permission' => ['superadmin'],
],
],
'podcasts' => [
[
'name' => 'create',
'description' => 'Add a new podcast',
'has_permission' => ['superadmin'],
],
[
'name' => 'import',
'description' => 'Import a new podcast from an external feed',
'has_permission' => ['superadmin'],
],
[
'name' => 'list',
'description' => 'List all podcasts and their episodes',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any podcast and their contributors list',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete',
'description' =>
'Delete a podcast without removing it from database',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete_permanently',
'description' => 'Delete any podcast from the database',
'has_permission' => ['superadmin'],
],
],
'episodes' => [
[
'name' => 'list',
'description' => 'List all episodes of any podcast',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any episode of any podcast',
'has_permission' => ['superadmin'],
],
],
'podcast' => [
[
'name' => 'view',
'description' => 'View a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'edit',
'description' => 'Edit a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_contributors',
'description' =>
'Add / remove contributors to a podcast and edit their roles',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_platforms',
'description' => 'Set / remove platform links of a podcast',
'has_permission' => ['podcast_admin'],
],
],
'podcast_episodes' => [
[
'name' => 'list',
'description' => 'List all episodes of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'view',
'description' => 'View any episode of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'create',
'description' => 'Add new episodes for a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'edit',
'description' => 'Edit an episode of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'delete',
'description' =>
'Delete an episode of a podcast without removing it from the database',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'delete_permanently',
'description' =>
'Delete all occurrences of an episode of a podcast from the database',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_publications',
'description' => 'Publish / unpublish episodes of a podcast',
'has_permission' => ['podcast_admin'],
],
],
];
static function getGroupIdByName($name, $dataGroups)
{
foreach ($dataGroups as $group) {
if ($group['name'] === $name) {
return $group['id'];
}
}
return null;
}
public function run()
{
$groupId = 0;
$dataGroups = [];
foreach ($this->groups as $group) {
array_push($dataGroups, [
'id' => ++$groupId,
'name' => $group['name'],
'description' => $group['description'],
]);
}
// Map permissions to a format the `auth_permissions` table expects
$dataPermissions = [];
$dataGroupsPermissions = [];
$permissionId = 0;
foreach ($this->permissions as $context => $actions) {
foreach ($actions as $action) {
array_push($dataPermissions, [
'id' => ++$permissionId,
'name' => $context . '-' . $action['name'],
'description' => $action['description'],
]);
foreach ($action['has_permission'] as $role) {
// link permission to specified groups
array_push($dataGroupsPermissions, [
'group_id' => $this->getGroupIdByName(
$role,
$dataGroups
),
'permission_id' => $permissionId,
]);
}
}
}
$this->db->table('auth_permissions')->insertBatch($dataPermissions);
$this->db->table('auth_groups')->insertBatch($dataGroups);
$this->db
->table('auth_groups_permissions')
->insertBatch($dataGroupsPermissions);
}
}
<?php
declare(strict_types=1);
/**
* Class CategorySeeder
* Inserts values in categories table in database
* Class CategorySeeder Inserts values in categories table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
......@@ -12,791 +13,791 @@
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class CategorySeeder extends Seeder
{
public function run()
#[Override]
public function run(): void
{
$data = [
[
'parent_id' => 0,
'id' => 0,
'code' => 'uncategorized',
'apple_category' => 'uncategorized',
'google_category' => 'uncategorized',
],
[
'parent_id' => 0,
'id' => 1,
'code' => 'arts',
'apple_category' => 'Arts',
'id' => 1,
'parent_id' => null,
'code' => 'arts',
'apple_category' => 'Arts',
'google_category' => 'Arts',
],
[
'parent_id' => 0,
'id' => 2,
'code' => 'business',
'apple_category' => 'Business',
'id' => 2,
'parent_id' => null,
'code' => 'business',
'apple_category' => 'Business',
'google_category' => 'Business',
],
[
'parent_id' => 0,
'id' => 3,
'code' => 'comedy',
'apple_category' => 'Comedy',
'id' => 3,
'parent_id' => null,
'code' => 'comedy',
'apple_category' => 'Comedy',
'google_category' => 'Comedy',
],
[
'parent_id' => 0,
'id' => 4,
'code' => 'education',
'apple_category' => 'Education',
'id' => 4,
'parent_id' => null,
'code' => 'education',
'apple_category' => 'Education',
'google_category' => 'Education',
],
[
'parent_id' => 0,
'id' => 5,
'code' => 'fiction',
'apple_category' => 'Fiction',
'id' => 5,
'parent_id' => null,
'code' => 'fiction',
'apple_category' => 'Fiction',
'google_category' => '',
],
[
'parent_id' => 0,
'id' => 6,
'code' => 'government',
'apple_category' => 'Government',
'google_category' => 'Government &amp; Organizations',
'id' => 6,
'parent_id' => null,
'code' => 'government',
'apple_category' => 'Government',
'google_category' => 'Government & Organizations',
],
[
'parent_id' => 0,
'id' => 7,
'code' => 'health_and_fitness',
'apple_category' => 'Health &amp; Fitness',
'id' => 7,
'parent_id' => null,
'code' => 'health_and_fitness',
'apple_category' => 'Health & Fitness',
'google_category' => 'Health',
],
[
'parent_id' => 0,
'id' => 8,
'code' => 'history',
'apple_category' => 'History',
'id' => 8,
'parent_id' => null,
'code' => 'history',
'apple_category' => 'History',
'google_category' => '',
],
[
'parent_id' => 0,
'id' => 9,
'code' => 'kids_and_family',
'apple_category' => 'Kids &amp; Family',
'google_category' => 'Kids &amp; Family',
'id' => 9,
'parent_id' => null,
'code' => 'kids_and_family',
'apple_category' => 'Kids & Family',
'google_category' => 'Kids & Family',
],
[
'parent_id' => 0,
'id' => 10,
'code' => 'leisure',
'apple_category' => 'Leisure',
'google_category' => 'Games &amp; Hobbies',
'id' => 10,
'parent_id' => null,
'code' => 'leisure',
'apple_category' => 'Leisure',
'google_category' => 'Games & Hobbies',
],
[
'parent_id' => 0,
'id' => 11,
'code' => 'music',
'apple_category' => 'Music',
'id' => 11,
'parent_id' => null,
'code' => 'music',
'apple_category' => 'Music',
'google_category' => 'Music',
],
[
'parent_id' => 0,
'id' => 12,
'code' => 'news',
'apple_category' => 'News',
'google_category' => 'News &amp; Politics',
'id' => 12,
'parent_id' => null,
'code' => 'news',
'apple_category' => 'News',
'google_category' => 'News & Politics',
],
[
'parent_id' => 0,
'id' => 13,
'code' => 'religion_and_spirituality',
'apple_category' => 'Religion &amp; Spirituality',
'google_category' => 'Religion &amp; Spirituality',
'id' => 13,
'parent_id' => null,
'code' => 'religion_and_spirituality',
'apple_category' => 'Religion & Spirituality',
'google_category' => 'Religion & Spirituality',
],
[
'parent_id' => 0,
'id' => 14,
'code' => 'science',
'apple_category' => 'Science',
'google_category' => 'Science &amp; Medicine',
'id' => 14,
'parent_id' => null,
'code' => 'science',
'apple_category' => 'Science',
'google_category' => 'Science & Medicine',
],
[
'parent_id' => 0,
'id' => 15,
'code' => 'society_and_culture',
'apple_category' => 'Society &amp; Culture',
'google_category' => 'Society &amp; Culture',
'id' => 15,
'parent_id' => null,
'code' => 'society_and_culture',
'apple_category' => 'Society & Culture',
'google_category' => 'Society & Culture',
],
[
'parent_id' => 0,
'id' => 16,
'code' => 'sports',
'apple_category' => 'Sports',
'google_category' => 'Sports &amp; Recreation',
'id' => 16,
'parent_id' => null,
'code' => 'sports',
'apple_category' => 'Sports',
'google_category' => 'Sports & Recreation',
],
[
'parent_id' => 0,
'id' => 17,
'code' => 'technology',
'apple_category' => 'Technology',
'id' => 17,
'parent_id' => null,
'code' => 'technology',
'apple_category' => 'Technology',
'google_category' => 'Technology',
],
[
'parent_id' => 0,
'id' => 18,
'code' => 'true_crime',
'apple_category' => 'True Crime',
'id' => 18,
'parent_id' => null,
'code' => 'true_crime',
'apple_category' => 'True Crime',
'google_category' => '',
],
[
'parent_id' => 0,
'id' => 19,
'code' => 'tv_and_film',
'apple_category' => 'TV &amp; Film',
'google_category' => 'TV &amp; Film',
'id' => 19,
'parent_id' => null,
'code' => 'tv_and_film',
'apple_category' => 'TV & Film',
'google_category' => 'TV & Film',
],
[
'parent_id' => 1,
'id' => 20,
'code' => 'books',
'apple_category' => 'Books',
'id' => 20,
'parent_id' => 1,
'code' => 'books',
'apple_category' => 'Books',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 21,
'code' => 'design',
'apple_category' => 'Design',
'id' => 21,
'parent_id' => 1,
'code' => 'design',
'apple_category' => 'Design',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 22,
'code' => 'fashion_and_beauty',
'apple_category' => 'Fashion &amp; Beauty',
'id' => 22,
'parent_id' => 1,
'code' => 'fashion_and_beauty',
'apple_category' => 'Fashion & Beauty',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 23,
'code' => 'food',
'apple_category' => 'Food',
'id' => 23,
'parent_id' => 1,
'code' => 'food',
'apple_category' => 'Food',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 24,
'code' => 'performing_arts',
'apple_category' => 'Performing Arts',
'id' => 24,
'parent_id' => 1,
'code' => 'performing_arts',
'apple_category' => 'Performing Arts',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 25,
'code' => 'visual_arts',
'apple_category' => 'Visual Arts',
'id' => 25,
'parent_id' => 1,
'code' => 'visual_arts',
'apple_category' => 'Visual Arts',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 26,
'code' => 'careers',
'apple_category' => 'Careers',
'id' => 26,
'parent_id' => 2,
'code' => 'careers',
'apple_category' => 'Careers',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 27,
'code' => 'entrepreneurship',
'apple_category' => 'Entrepreneurship',
'id' => 27,
'parent_id' => 2,
'code' => 'entrepreneurship',
'apple_category' => 'Entrepreneurship',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 28,
'code' => 'investing',
'apple_category' => 'Investing',
'id' => 28,
'parent_id' => 2,
'code' => 'investing',
'apple_category' => 'Investing',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 29,
'code' => 'management',
'apple_category' => 'Management',
'id' => 29,
'parent_id' => 2,
'code' => 'management',
'apple_category' => 'Management',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 30,
'code' => 'marketing',
'apple_category' => 'Marketing',
'id' => 30,
'parent_id' => 2,
'code' => 'marketing',
'apple_category' => 'Marketing',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 31,
'code' => 'non_profit',
'apple_category' => 'Non-Profit',
'id' => 31,
'parent_id' => 2,
'code' => 'non_profit',
'apple_category' => 'Non-Profit',
'google_category' => '',
],
[
'parent_id' => 3,
'id' => 32,
'code' => 'comedy_interviews',
'apple_category' => 'Comedy Interviews',
'id' => 32,
'parent_id' => 3,
'code' => 'comedy_interviews',
'apple_category' => 'Comedy Interviews',
'google_category' => '',
],
[
'parent_id' => 3,
'id' => 33,
'code' => 'improv',
'apple_category' => 'Improv',
'id' => 33,
'parent_id' => 3,
'code' => 'improv',
'apple_category' => 'Improv',
'google_category' => '',
],
[
'parent_id' => 3,
'id' => 34,
'code' => 'stand_up',
'apple_category' => 'Stand-Up',
'id' => 34,
'parent_id' => 3,
'code' => 'stand_up',
'apple_category' => 'Stand-Up',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 35,
'code' => 'courses',
'apple_category' => 'Courses',
'id' => 35,
'parent_id' => 4,
'code' => 'courses',
'apple_category' => 'Courses',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 36,
'code' => 'how_to',
'apple_category' => 'How To',
'id' => 36,
'parent_id' => 4,
'code' => 'how_to',
'apple_category' => 'How To',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 37,
'code' => 'language_learning',
'apple_category' => 'Language Learning',
'id' => 37,
'parent_id' => 4,
'code' => 'language_learning',
'apple_category' => 'Language Learning',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 38,
'code' => 'self_improvement',
'apple_category' => 'Self-Improvement',
'id' => 38,
'parent_id' => 4,
'code' => 'self_improvement',
'apple_category' => 'Self-Improvement',
'google_category' => '',
],
[
'parent_id' => 5,
'id' => 39,
'code' => 'comedy_fiction',
'apple_category' => 'Comedy Fiction',
'id' => 39,
'parent_id' => 5,
'code' => 'comedy_fiction',
'apple_category' => 'Comedy Fiction',
'google_category' => '',
],
[
'parent_id' => 5,
'id' => 40,
'code' => 'drama',
'apple_category' => 'Drama',
'id' => 40,
'parent_id' => 5,
'code' => 'drama',
'apple_category' => 'Drama',
'google_category' => '',
],
[
'parent_id' => 5,
'id' => 41,
'code' => 'science_fiction',
'apple_category' => 'Science Fiction',
'id' => 41,
'parent_id' => 5,
'code' => 'science_fiction',
'apple_category' => 'Science Fiction',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 42,
'code' => 'alternative_health',
'apple_category' => 'Alternative Health',
'id' => 42,
'parent_id' => 7,
'code' => 'alternative_health',
'apple_category' => 'Alternative Health',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 43,
'code' => 'fitness',
'apple_category' => 'Fitness',
'id' => 43,
'parent_id' => 7,
'code' => 'fitness',
'apple_category' => 'Fitness',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 44,
'code' => 'medicine',
'apple_category' => 'Medicine',
'id' => 44,
'parent_id' => 7,
'code' => 'medicine',
'apple_category' => 'Medicine',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 45,
'code' => 'mental_health',
'apple_category' => 'Mental Health',
'id' => 45,
'parent_id' => 7,
'code' => 'mental_health',
'apple_category' => 'Mental Health',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 46,
'code' => 'nutrition',
'apple_category' => 'Nutrition',
'id' => 46,
'parent_id' => 7,
'code' => 'nutrition',
'apple_category' => 'Nutrition',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 47,
'code' => 'sexuality',
'apple_category' => 'Sexuality',
'id' => 47,
'parent_id' => 7,
'code' => 'sexuality',
'apple_category' => 'Sexuality',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 48,
'code' => 'education_for_kids',
'apple_category' => 'Education for Kids',
'id' => 48,
'parent_id' => 9,
'code' => 'education_for_kids',
'apple_category' => 'Education for Kids',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 49,
'code' => 'parenting',
'apple_category' => 'Parenting',
'id' => 49,
'parent_id' => 9,
'code' => 'parenting',
'apple_category' => 'Parenting',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 50,
'code' => 'pets_and_animals',
'apple_category' => 'Pets &amp; Animals',
'id' => 50,
'parent_id' => 9,
'code' => 'pets_and_animals',
'apple_category' => 'Pets & Animals',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 51,
'code' => 'stories_for_kids',
'apple_category' => 'Stories for Kids',
'id' => 51,
'parent_id' => 9,
'code' => 'stories_for_kids',
'apple_category' => 'Stories for Kids',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 52,
'code' => 'animation_and_manga',
'apple_category' => 'Animation &amp; Manga',
'id' => 52,
'parent_id' => 10,
'code' => 'animation_and_manga',
'apple_category' => 'Animation & Manga',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 53,
'code' => 'automotive',
'apple_category' => 'Automotive',
'id' => 53,
'parent_id' => 10,
'code' => 'automotive',
'apple_category' => 'Automotive',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 54,
'code' => 'aviation',
'apple_category' => 'Aviation',
'id' => 54,
'parent_id' => 10,
'code' => 'aviation',
'apple_category' => 'Aviation',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 55,
'code' => 'crafts',
'apple_category' => 'Crafts',
'id' => 55,
'parent_id' => 10,
'code' => 'crafts',
'apple_category' => 'Crafts',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 56,
'code' => 'games',
'apple_category' => 'Games',
'id' => 56,
'parent_id' => 10,
'code' => 'games',
'apple_category' => 'Games',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 57,
'code' => 'hobbies',
'apple_category' => 'Hobbies',
'id' => 57,
'parent_id' => 10,
'code' => 'hobbies',
'apple_category' => 'Hobbies',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 58,
'code' => 'home_and_garden',
'apple_category' => 'Home &amp; Garden',
'id' => 58,
'parent_id' => 10,
'code' => 'home_and_garden',
'apple_category' => 'Home & Garden',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 59,
'code' => 'video_games',
'apple_category' => 'Video Games',
'id' => 59,
'parent_id' => 10,
'code' => 'video_games',
'apple_category' => 'Video Games',
'google_category' => '',
],
[
'parent_id' => 11,
'id' => 60,
'code' => 'music_commentary',
'apple_category' => 'Music Commentary',
'id' => 60,
'parent_id' => 11,
'code' => 'music_commentary',
'apple_category' => 'Music Commentary',
'google_category' => '',
],
[
'parent_id' => 11,
'id' => 61,
'code' => 'music_history',
'apple_category' => 'Music History',
'id' => 61,
'parent_id' => 11,
'code' => 'music_history',
'apple_category' => 'Music History',
'google_category' => '',
],
[
'parent_id' => 11,
'id' => 62,
'code' => 'music_interviews',
'apple_category' => 'Music Interviews',
'id' => 62,
'parent_id' => 11,
'code' => 'music_interviews',
'apple_category' => 'Music Interviews',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 63,
'code' => 'business_news',
'apple_category' => 'Business News',
'id' => 63,
'parent_id' => 12,
'code' => 'business_news',
'apple_category' => 'Business News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 64,
'code' => 'daily_news',
'apple_category' => 'Daily News',
'id' => 64,
'parent_id' => 12,
'code' => 'daily_news',
'apple_category' => 'Daily News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 65,
'code' => 'entertainment_news',
'apple_category' => 'Entertainment News',
'id' => 65,
'parent_id' => 12,
'code' => 'entertainment_news',
'apple_category' => 'Entertainment News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 66,
'code' => 'news_commentary',
'apple_category' => 'News Commentary',
'id' => 66,
'parent_id' => 12,
'code' => 'news_commentary',
'apple_category' => 'News Commentary',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 67,
'code' => 'politics',
'apple_category' => 'Politics',
'id' => 67,
'parent_id' => 12,
'code' => 'politics',
'apple_category' => 'Politics',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 68,
'code' => 'sports_news',
'apple_category' => 'Sports News',
'id' => 68,
'parent_id' => 12,
'code' => 'sports_news',
'apple_category' => 'Sports News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 69,
'code' => 'tech_news',
'apple_category' => 'Tech News',
'id' => 69,
'parent_id' => 12,
'code' => 'tech_news',
'apple_category' => 'Tech News',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 70,
'code' => 'buddhism',
'apple_category' => 'Buddhism',
'id' => 70,
'parent_id' => 13,
'code' => 'buddhism',
'apple_category' => 'Buddhism',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 71,
'code' => 'christianity',
'apple_category' => 'Christianity',
'id' => 71,
'parent_id' => 13,
'code' => 'christianity',
'apple_category' => 'Christianity',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 72,
'code' => 'hinduism',
'apple_category' => 'Hinduism',
'id' => 72,
'parent_id' => 13,
'code' => 'hinduism',
'apple_category' => 'Hinduism',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 73,
'code' => 'islam',
'apple_category' => 'Islam',
'id' => 73,
'parent_id' => 13,
'code' => 'islam',
'apple_category' => 'Islam',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 74,
'code' => 'judaism',
'apple_category' => 'Judaism',
'id' => 74,
'parent_id' => 13,
'code' => 'judaism',
'apple_category' => 'Judaism',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 75,
'code' => 'religion',
'apple_category' => 'Religion',
'id' => 75,
'parent_id' => 13,
'code' => 'religion',
'apple_category' => 'Religion',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 76,
'code' => 'spirituality',
'apple_category' => 'Spirituality',
'id' => 76,
'parent_id' => 13,
'code' => 'spirituality',
'apple_category' => 'Spirituality',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 77,
'code' => 'astronomy',
'apple_category' => 'Astronomy',
'id' => 77,
'parent_id' => 14,
'code' => 'astronomy',
'apple_category' => 'Astronomy',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 78,
'code' => 'chemistry',
'apple_category' => 'Chemistry',
'id' => 78,
'parent_id' => 14,
'code' => 'chemistry',
'apple_category' => 'Chemistry',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 79,
'code' => 'earth_sciences',
'apple_category' => 'Earth Sciences',
'id' => 79,
'parent_id' => 14,
'code' => 'earth_sciences',
'apple_category' => 'Earth Sciences',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 80,
'code' => 'life_sciences',
'apple_category' => 'Life Sciences',
'id' => 80,
'parent_id' => 14,
'code' => 'life_sciences',
'apple_category' => 'Life Sciences',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 81,
'code' => 'mathematics',
'apple_category' => 'Mathematics',
'id' => 81,
'parent_id' => 14,
'code' => 'mathematics',
'apple_category' => 'Mathematics',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 82,
'code' => 'natural_sciences',
'apple_category' => 'Natural Sciences',
'id' => 82,
'parent_id' => 14,
'code' => 'natural_sciences',
'apple_category' => 'Natural Sciences',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 83,
'code' => 'nature',
'apple_category' => 'Nature',
'id' => 83,
'parent_id' => 14,
'code' => 'nature',
'apple_category' => 'Nature',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 84,
'code' => 'physics',
'apple_category' => 'Physics',
'id' => 84,
'parent_id' => 14,
'code' => 'physics',
'apple_category' => 'Physics',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 85,
'code' => 'social_sciences',
'apple_category' => 'Social Sciences',
'id' => 85,
'parent_id' => 14,
'code' => 'social_sciences',
'apple_category' => 'Social Sciences',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 86,
'code' => 'documentary',
'apple_category' => 'Documentary',
'id' => 86,
'parent_id' => 15,
'code' => 'documentary',
'apple_category' => 'Documentary',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 87,
'code' => 'personal_journals',
'apple_category' => 'Personal Journals',
'id' => 87,
'parent_id' => 15,
'code' => 'personal_journals',
'apple_category' => 'Personal Journals',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 88,
'code' => 'philosophy',
'apple_category' => 'Philosophy',
'id' => 88,
'parent_id' => 15,
'code' => 'philosophy',
'apple_category' => 'Philosophy',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 89,
'code' => 'places_and_travel',
'apple_category' => 'Places &amp; Travel',
'id' => 89,
'parent_id' => 15,
'code' => 'places_and_travel',
'apple_category' => 'Places & Travel',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 90,
'code' => 'relationships',
'apple_category' => 'Relationships',
'id' => 90,
'parent_id' => 15,
'code' => 'relationships',
'apple_category' => 'Relationships',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 91,
'code' => 'baseball',
'apple_category' => 'Baseball',
'id' => 91,
'parent_id' => 16,
'code' => 'baseball',
'apple_category' => 'Baseball',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 92,
'code' => 'basketball',
'apple_category' => 'Basketball',
'id' => 92,
'parent_id' => 16,
'code' => 'basketball',
'apple_category' => 'Basketball',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 93,
'code' => 'cricket',
'apple_category' => 'Cricket',
'id' => 93,
'parent_id' => 16,
'code' => 'cricket',
'apple_category' => 'Cricket',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 94,
'code' => 'fantasy_sports',
'apple_category' => 'Fantasy Sports',
'id' => 94,
'parent_id' => 16,
'code' => 'fantasy_sports',
'apple_category' => 'Fantasy Sports',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 95,
'code' => 'football',
'apple_category' => 'Football',
'id' => 95,
'parent_id' => 16,
'code' => 'football',
'apple_category' => 'Football',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 96,
'code' => 'golf',
'apple_category' => 'Golf',
'id' => 96,
'parent_id' => 16,
'code' => 'golf',
'apple_category' => 'Golf',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 97,
'code' => 'hockey',
'apple_category' => 'Hockey',
'id' => 97,
'parent_id' => 16,
'code' => 'hockey',
'apple_category' => 'Hockey',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 98,
'code' => 'rugby',
'apple_category' => 'Rugby',
'id' => 98,
'parent_id' => 16,
'code' => 'rugby',
'apple_category' => 'Rugby',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 99,
'code' => 'running',
'apple_category' => 'Running',
'id' => 99,
'parent_id' => 16,
'code' => 'running',
'apple_category' => 'Running',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 100,
'code' => 'soccer',
'apple_category' => 'Soccer',
'id' => 100,
'parent_id' => 16,
'code' => 'soccer',
'apple_category' => 'Soccer',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 101,
'code' => 'swimming',
'apple_category' => 'Swimming',
'id' => 101,
'parent_id' => 16,
'code' => 'swimming',
'apple_category' => 'Swimming',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 102,
'code' => 'tennis',
'apple_category' => 'Tennis',
'id' => 102,
'parent_id' => 16,
'code' => 'tennis',
'apple_category' => 'Tennis',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 103,
'code' => 'volleyball',
'apple_category' => 'Volleyball',
'id' => 103,
'parent_id' => 16,
'code' => 'volleyball',
'apple_category' => 'Volleyball',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 104,
'code' => 'wilderness',
'apple_category' => 'Wilderness',
'id' => 104,
'parent_id' => 16,
'code' => 'wilderness',
'apple_category' => 'Wilderness',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 105,
'code' => 'wrestling',
'apple_category' => 'Wrestling',
'id' => 105,
'parent_id' => 16,
'code' => 'wrestling',
'apple_category' => 'Wrestling',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 106,
'code' => 'after_shows',
'apple_category' => 'After Shows',
'id' => 106,
'parent_id' => 19,
'code' => 'after_shows',
'apple_category' => 'After Shows',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 107,
'code' => 'film_history',
'apple_category' => 'Film History',
'id' => 107,
'parent_id' => 19,
'code' => 'film_history',
'apple_category' => 'Film History',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 108,
'code' => 'film_interviews',
'apple_category' => 'Film Interviews',
'id' => 108,
'parent_id' => 19,
'code' => 'film_interviews',
'apple_category' => 'Film Interviews',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 109,
'code' => 'film_reviews',
'apple_category' => 'Film Reviews',
'id' => 109,
'parent_id' => 19,
'code' => 'film_reviews',
'apple_category' => 'Film Reviews',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 110,
'code' => 'tv_reviews',
'apple_category' => 'TV Reviews',
'id' => 110,
'parent_id' => 19,
'code' => 'tv_reviews',
'apple_category' => 'TV Reviews',
'google_category' => '',
],
];
$this->db->table('categories')->insertBatch($data);
foreach ($data as $categoryLine) {
$this->db
->table('categories')
->ignore(true)
->insert($categoryLine);
}
}
}
<?php
declare(strict_types=1);
/**
* Class AppSeeder Calls all required seeders for castopod to work properly
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class DevSeeder extends Seeder
{
#[Override]
public function run(): void
{
$this->call('CategorySeeder');
$this->call('LanguageSeeder');
$this->call('DevSuperadminSeeder');
}
}
<?php
declare(strict_types=1);
/**
* Class TestSeeder Inserts a superadmin user in the database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use CodeIgniter\Shield\Entities\User;
use Modules\Auth\Models\UserModel;
use Override;
class DevSuperadminSeeder extends Seeder
{
#[Override]
public function run(): void
{
if ((new UserModel())->where('is_owner', true)->first() instanceof User) {
return;
}
/**
* Inserts an owner with the following credentials: admin: `admin@example.com` password: `castopod`
*/
// Get the User Provider (UserModel by default)
$users = auth()
->getProvider();
$user = new User([
'username' => 'admin',
'email' => 'admin@castopod.local',
'password' => 'castopod',
'is_owner' => true,
]);
$users->save($user);
// To get the complete user object with ID, we need to get from the database
$user = $users->findById($users->getInsertID());
$user->addGroup(setting('AuthGroups.mostPowerfulGroup'));
}
}
<?php
declare(strict_types=1);
/**
* Class FakePodcastsAnalyticsSeeder Inserts Fake Analytics in the database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use App\Entities\Episode;
use App\Entities\Podcast;
use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use CodeIgniter\Database\Seeder;
use Exception;
use GeoIp2\Database\Reader;
use GeoIp2\Exception\AddressNotFoundException;
use Override;
class FakePodcastsAnalyticsSeeder extends Seeder
{
#[Override]
public function run(): void
{
$jsonUserAgents = json_decode(
file_get_contents('https://raw.githubusercontent.com/opawg/user-agents/master/src/user-agents.json'),
true,
512,
JSON_THROW_ON_ERROR,
);
$jsonRSSUserAgents = json_decode(
file_get_contents(
'https://raw.githubusercontent.com/opawg/podcast-rss-useragents/master/src/rss-ua.json',
),
true,
512,
JSON_THROW_ON_ERROR,
);
$podcast = (new PodcastModel())->first();
if (! $podcast instanceof Podcast) {
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n");
}
$firstEpisode = (new EpisodeModel())
->selectMin('published_at')
->first();
if (! $firstEpisode instanceof Episode) {
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate an episode first.");
}
for (
$date = strtotime((string) $firstEpisode->published_at);
$date < strtotime('now');
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
) {
$analyticsPodcasts = [];
$analyticsPodcastsByHour = [];
$analyticsPodcastsByCountry = [];
$analyticsPodcastsByEpisode = [];
$analyticsPodcastsByPlayer = [];
$analyticsPodcastsByRegion = [];
$episodes = (new EpisodeModel())
->where('podcast_id', $podcast->id)
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->findAll();
foreach ($episodes as $episode) {
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
$probability1 = floor(exp(3 - $age / 40)) + 1;
for (
$lineNumber = 0;
$lineNumber < random_int(1, (int) $probability1);
++$lineNumber
) {
$probability2 = floor(exp(6 - $age / 20)) + 10;
$player =
$jsonUserAgents[
random_int(1, count($jsonUserAgents) - 1)
];
$service =
$jsonRSSUserAgents[
random_int(1, count($jsonRSSUserAgents) - 1)
]['slug'];
$app = $player['app'] ?? '';
$device = $player['device'] ?? '';
$os = $player['os'] ?? '';
$isBot = $player['bot'] ?? 0;
$fakeIp =
random_int(0, 255) .
'.' .
random_int(0, 255) .
'.' .
random_int(0, 255) .
'.' .
random_int(0, 255);
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb');
$countryCode = 'N/A';
$regionCode = 'N/A';
$latitude = null;
$longitude = null;
try {
$city = $cityReader->city($fakeIp);
$countryCode = $city->country->isoCode ?? 'N/A';
$regionCode = $city->subdivisions === []
? 'N/A'
: $city->subdivisions[0]->isoCode;
$latitude = round((float) $city->location->latitude, 3);
$longitude = round((float) $city->location->longitude, 3);
} catch (AddressNotFoundException) {
//Bad luck, bad IP, nothing to do.
}
$hits = random_int(0, (int) $probability2);
$analyticsPodcasts[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'duration' => random_int(60, 3600),
'bandwidth' => random_int(1000000, 10000000),
'hits' => $hits,
'unique_listeners' => $hits,
];
$analyticsPodcastsByHour[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'hour' => random_int(0, 23),
'hits' => $hits,
];
$analyticsPodcastsByCountry[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'country_code' => $countryCode,
'hits' => $hits,
];
$analyticsPodcastsByEpisode[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'episode_id' => $episode->id,
'age' => $age,
'hits' => $hits,
];
$analyticsPodcastsByPlayer[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'service' => $service,
'app' => $app,
'device' => $device,
'os' => $os,
'is_bot' => $isBot,
'hits' => $hits,
];
$analyticsPodcastsByRegion[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'country_code' => $countryCode,
'region_code' => $regionCode,
'latitude' => $latitude,
'longitude' => $longitude,
'hits' => $hits,
];
}
}
$this->db
->table('analytics_podcasts')
->ignore(true)
->insertBatch($analyticsPodcasts);
$this->db
->table('analytics_podcasts_by_hour')
->ignore(true)
->insertBatch($analyticsPodcastsByHour);
$this->db
->table('analytics_podcasts_by_country')
->ignore(true)
->insertBatch($analyticsPodcastsByCountry);
$this->db
->table('analytics_podcasts_by_episode')
->ignore(true)
->insertBatch($analyticsPodcastsByEpisode);
$this->db
->table('analytics_podcasts_by_player')
->ignore(true)
->insertBatch($analyticsPodcastsByPlayer);
$this->db
->table('analytics_podcasts_by_region')
->ignore(true)
->insertBatch($analyticsPodcastsByRegion);
}
}
}
<?php
declare(strict_types=1);
/**
* Class FakeWebsiteAnalyticsSeeder Inserts Fake Analytics in the database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use App\Entities\Episode;
use App\Entities\Podcast;
use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use CodeIgniter\Database\Seeder;
use Exception;
use Override;
class FakeWebsiteAnalyticsSeeder extends Seeder
{
/**
* @var string[]
*/
protected array $keywords = [
'all the smoke podcast',
'apple podcast',
'bad friends podcast',
'best podcast',
'best podcasts',
'best podcasts 2020',
'blood ties',
'call her daddy',
'call her daddy podcast',
'call her daddy podcast controversy',
'call her daddy podcast drama',
'counter clock podcast',
'counterclock podcast',
'crime junkie podcast',
'crime podcast',
'down the hill podcast',
'gerry callahan podcast',
'google podcast',
'history podcast',
'joe rogan',
'joe rogan podcast',
'lana rhoades and logan paul podcast',
'last podcast on the left',
'michael moore podcast',
'michelle obama podcast',
'missing in alaska podcast',
'murder podcast',
'nice white parents podcast',
'nick cannon podcast',
'npr podcast',
'office ladies podcast',
'podcast app',
'podcasts',
'rogan podcast',
'rudy giuliani podcast',
'savage podcast',
'serial podcast',
'smartless podcast',
'ted cruz podcast',
'the daily',
'the daily podcast',
'the last podcast on the left',
'the new abnormal podcast',
'tiger king podcast',
'trey gowdy podcast',
'true crime podcast',
'what is a podcast',
'what is podcast',
'wind of change podcast',
'your own backyard podcast',
];
/**
* @var string[]
*/
protected array $domains = [
'360.cn ',
'adobe.com ',
'aliexpress.com ',
'alipay.com ',
'amazon.co.jp ',
'amazon.com ',
'amazon.in ',
'apple.com ',
'baidu.com ',
'bing.com ',
'bongacams.com ',
'chaturbate.com ',
'china.com.cn ',
'csdn.net ',
'ebay.com ',
'facebook.com ',
'google.co.in ',
'google.com ',
'google.com.hk ',
'instagram.com ',
'jd.com ',
'live.com ',
'livejasmin.com ',
'microsoft.com ',
'microsoftonline.com ',
'myshopify.com ',
'naver.com ',
'netflix.com ',
'office.com ',
'okezone.com ',
'panda.tv ',
'qq.com ',
'reddit.com ',
'sina.com.cn ',
'sohu.com ',
'taobao.com ',
'tianya.cn ',
'tmall.com ',
'tribunnews.com ',
'twitch.tv ',
'twitter.com ',
'vk.com ',
'weibo.com ',
'wikipedia.org ',
'xinhuanet.com ',
'yahoo.co.jp ',
'yahoo.com ',
'youtube.com ',
'zhanqi.tv ',
'zoom.us ',
];
/**
* @var string[]
*/
protected array $browsers = [
'Android Browser',
'Avast Secure Browser',
'BlackBerry Browser',
'Chrome',
'Chrome Mobile',
'Chrome Mobile iOS',
'Chrome Webview',
'Chromium',
'Ecosia',
'Fennec',
'Firebird',
'Firefox',
'Firefox Mobile',
'Firefox Mobile iOS',
'Galeon',
'GNOME Web',
'Headless Chrome',
'Huawei Browser',
'IE Mobile',
'Inconnu',
'Internet Explorer',
'Kindle Browser',
'Konqueror',
'Maxthon',
'Meizu Browser',
'Microsoft Edge',
'MIUI Browser',
'Mobile Safari',
'Mobile Silk',
'OmniWeb',
'Openwave Mobile Browser',
'Opera',
'Opera Mini',
'Opera Mobile',
'Opera Next',
'Palm Blazer',
'Puffin',
'QupZilla',
'Safari',
'Samsung Browser',
'UC Browser',
'WOSBrowser',
];
#[Override]
public function run(): void
{
$podcast = (new PodcastModel())->first();
if (! $podcast instanceof Podcast) {
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n");
}
$firstEpisode = (new EpisodeModel())
->selectMin('published_at')
->first();
if (! $firstEpisode instanceof Episode) {
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate an episode first.");
}
for (
$date = strtotime((string) $firstEpisode->published_at);
$date < strtotime('now');
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
) {
$websiteByBrowser = [];
$websiteByEntryPage = [];
$websiteByReferer = [];
$episodes = (new EpisodeModel())
->where('podcast_id', $podcast->id)
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->findAll();
foreach ($episodes as $episode) {
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
$probability1 = (int) floor(exp(3 - $age / 40)) + 1;
for (
$lineNumber = 0;
$lineNumber < random_int(1, $probability1);
++$lineNumber
) {
$probability2 = (int) floor(exp(6 - $age / 20)) + 10;
$domain =
$this->domains[random_int(0, count($this->domains) - 1)];
$keyword =
$this->keywords[
random_int(0, count($this->keywords) - 1)
];
$browser =
$this->browsers[
random_int(0, count($this->browsers) - 1)
];
$hits = random_int(0, $probability2);
$websiteByBrowser[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'browser' => $browser,
'hits' => $hits,
];
$websiteByEntryPage[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'entry_page_url' => $episode->link,
'hits' => $hits,
];
$websiteByReferer[] = [
'podcast_id' => $podcast->id,
'date' => date('Y-m-d', $date),
'referer_url' => 'http://' . $domain . '/?q=' . $keyword,
'domain' => $domain,
'keywords' => $keyword,
'hits' => $hits,
];
}
}
$this->db
->table('analytics_website_by_browser')
->ignore(true)
->insertBatch($websiteByBrowser);
$this->db
->table('analytics_website_by_entry_page')
->ignore(true)
->insertBatch($websiteByEntryPage);
$this->db
->table('analytics_website_by_referer')
->ignore(true)
->insertBatch($websiteByReferer);
}
}
}
<?php
declare(strict_types=1);
/**
* Class LanguageSeeder
* Inserts values in languages table in database
* Class LanguageSeeder Inserts values in languages table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
/**
* From https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
* (cc) Creative Commons Attribution-ShareAlike 3.0
* From https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes (cc) Creative Commons Attribution-ShareAlike 3.0
* 2020-06-07
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class LanguageSeeder extends Seeder
{
public function run()
#[Override]
public function run(): void
{
$data = [
['code' => 'aa', 'name' => 'Afar', 'native_name' => 'Afaraf'],
[
'code' => 'ab',
'name' => 'Abkhazian',
'code' => 'aa',
'native_name' => 'Afaraf',
],
[
'code' => 'ab',
'native_name' => 'аҧсуа бызшәа, аҧсшәа',
],
['code' => 'ae', 'name' => 'Avestan', 'native_name' => 'avesta'],
[
'code' => 'af',
'name' => 'Afrikaans',
'code' => 'ae',
'native_name' => 'Avesta',
],
[
'code' => 'af',
'native_name' => 'Afrikaans',
],
['code' => 'ak', 'name' => 'Akan', 'native_name' => 'Akan'],
['code' => 'am', 'name' => 'Amharic', 'native_name' => 'አማርኛ'],
[
'code' => 'an',
'name' => 'Aragonese',
'native_name' => 'aragonés',
'code' => 'ak',
'native_name' => 'Akan',
],
[
'code' => 'am',
'native_name' => 'አማርኛ',
],
[
'code' => 'an',
'native_name' => 'Aragonés',
],
[
'code' => 'ar',
'native_name' => 'العربية',
],
[
'code' => 'as',
'native_name' => 'অসমীয়া',
],
['code' => 'ar', 'name' => 'Arabic', 'native_name' => 'العربية'],
['code' => 'as', 'name' => 'Assamese', 'native_name' => 'অসমীয়া'],
[
'code' => 'av',
'name' => 'Avaric',
'code' => 'av',
'native_name' => 'авар мацӀ, магӀарул мацӀ',
],
['code' => 'ay', 'name' => 'Aymara', 'native_name' => 'aymar aru'],
[
'code' => 'az',
'name' => 'Azerbaijani',
'code' => 'ay',
'native_name' => 'Aymar aru',
],
[
'code' => 'az',
'native_name' => 'azərbaycan dili',
],
[
'code' => 'ba',
'name' => 'Bashkir',
'code' => 'ba',
'native_name' => 'башҡорт теле',
],
[
'code' => 'be',
'name' => 'Belarusian',
'code' => 'be',
'native_name' => 'беларуская мова',
],
[
'code' => 'bg',
'name' => 'Bulgarian',
'code' => 'bg',
'native_name' => 'български език',
],
[
'code' => 'bh',
'name' => 'Bihari languages',
'code' => 'bh',
'native_name' => 'भोजपुरी',
],
['code' => 'bi', 'name' => 'Bislama', 'native_name' => 'Bislama'],
[
'code' => 'bm',
'name' => 'Bambara',
'native_name' => 'bamanankan',
'code' => 'bi',
'native_name' => 'Bislama',
],
[
'code' => 'bm',
'native_name' => 'Bamanankan',
],
[
'code' => 'bn',
'native_name' => 'বাংলা',
],
[
'code' => 'bo',
'native_name' => 'བོད་ཡིག',
],
[
'code' => 'br',
'native_name' => 'Brezhoneg',
],
['code' => 'bn', 'name' => 'Bengali', 'native_name' => 'বাংলা'],
['code' => 'bo', 'name' => 'Tibetan', 'native_name' => 'བོད་ཡིག'],
['code' => 'br', 'name' => 'Breton', 'native_name' => 'brezhoneg'],
[
'code' => 'bs',
'name' => 'Bosnian',
'native_name' => 'bosanski jezik',
'code' => 'bs',
'native_name' => 'Bosanski jezik',
],
[
'code' => 'ca',
'name' => 'Catalan, Valencian',
'native_name' => 'català, valencià',
'code' => 'ca',
'native_name' => 'Català, valencià',
],
[
'code' => 'ce',
'name' => 'Chechen',
'code' => 'ce',
'native_name' => 'нохчийн мотт',
],
['code' => 'ch', 'name' => 'Chamorro', 'native_name' => 'Chamoru'],
[
'code' => 'co',
'name' => 'Corsican',
'native_name' => 'corsu, lingua corsa',
'code' => 'ch',
'native_name' => 'Chamoru',
],
[
'code' => 'co',
'native_name' => 'Corsu, lingua corsa',
],
['code' => 'cr', 'name' => 'Cree', 'native_name' => 'ᓀᐦᐃᔭᐍᐏᐣ'],
[
'code' => 'cs',
'name' => 'Czech',
'code' => 'cr',
'native_name' => 'ᓀᐦᐃᔭᐍᐏᐣ',
],
[
'code' => 'cs',
'native_name' => 'čeština, český jazyk',
],
[
'code' => 'cu',
'name' =>
'Church Slavic, Old Slavonic, Church Slavonic, Old Bulgarian, Old Church Slavonic',
'code' => 'cu',
'native_name' => 'ѩзыкъ словѣньскъ',
],
[
'code' => 'cv',
'name' => 'Chuvash',
'code' => 'cv',
'native_name' => 'чӑваш чӗлхи',
],
['code' => 'cy', 'name' => 'Welsh', 'native_name' => 'Cymraeg'],
['code' => 'da', 'name' => 'Danish', 'native_name' => 'dansk'],
['code' => 'de', 'name' => 'German', 'native_name' => 'Deutsch'],
[
'code' => 'dv',
'name' => 'Divehi, Dhivehi, Maldivian',
'code' => 'cy',
'native_name' => 'Cymraeg',
],
[
'code' => 'da',
'native_name' => 'Dansk',
],
[
'code' => 'de',
'native_name' => 'Deutsch',
],
[
'code' => 'dv',
'native_name' => 'ދިވެހި',
],
['code' => 'dz', 'name' => 'Dzongkha', 'native_name' => 'རྫོང་ཁ'],
['code' => 'ee', 'name' => 'Ewe', 'native_name' => 'Eʋegbe'],
[
'code' => 'el',
'name' => 'Greek, Modern (1453–)',
'code' => 'dz',
'native_name' => 'རྫོང་ཁ',
],
[
'code' => 'ee',
'native_name' => 'Eʋegbe',
],
[
'code' => 'el',
'native_name' => 'ελληνικά',
],
['code' => 'en', 'name' => 'English', 'native_name' => 'English'],
[
'code' => 'eo',
'name' => 'Esperanto',
'code' => 'en',
'native_name' => 'English',
],
[
'code' => 'eo',
'native_name' => 'Esperanto',
],
[
'code' => 'es',
'name' => 'Spanish, Castilian',
'code' => 'es',
'native_name' => 'Español',
],
[
'code' => 'et',
'name' => 'Estonian',
'code' => 'et',
'native_name' => 'eesti, eesti keel',
],
[
'code' => 'eu',
'name' => 'Basque',
'native_name' => 'euskara, euskera',
'code' => 'eu',
'native_name' => 'Euskara, euskera',
],
[
'code' => 'fa',
'native_name' => 'فارسی',
],
['code' => 'fa', 'name' => 'Persian', 'native_name' => 'فارسی'],
[
'code' => 'ff',
'name' => 'Fulah',
'code' => 'ff',
'native_name' => 'Fulfulde, Pulaar, Pular',
],
[
'code' => 'fi',
'name' => 'Finnish',
'native_name' => 'suomi, suomen kieli',
'code' => 'fi',
'native_name' => 'Suomi, suomen kieli',
],
[
'code' => 'fj',
'native_name' => 'Vosa Vakaviti',
],
[
'code' => 'fj',
'name' => 'Fijian',
'native_name' => 'vosa Vakaviti',
'code' => 'fo',
'native_name' => 'Føroyskt',
],
['code' => 'fo', 'name' => 'Faroese', 'native_name' => 'føroyskt'],
[
'code' => 'fr',
'name' => 'French',
'native_name' => 'français, langue française',
'code' => 'fr',
'native_name' => 'Français, langue française',
],
[
'code' => 'fy',
'name' => 'Western Frisian',
'code' => 'fy',
'native_name' => 'Frysk',
],
['code' => 'ga', 'name' => 'Irish', 'native_name' => 'Gaeilge'],
[
'code' => 'gd',
'name' => 'Gaelic, Scottish Gaelic',
'code' => 'ga',
'native_name' => 'Gaeilge',
],
[
'code' => 'gd',
'native_name' => 'Gàidhlig',
],
['code' => 'gl', 'name' => 'Galician', 'native_name' => 'Galego'],
['code' => 'gn', 'name' => 'Guarani', 'native_name' => 'Avañe\'ẽ'],
['code' => 'gu', 'name' => 'Gujarati', 'native_name' => 'ગુજરાતી'],
[
'code' => 'gv',
'name' => 'Manx',
'code' => 'gl',
'native_name' => 'Galego',
],
[
'code' => 'gn',
'native_name' => "Avañe'ẽ",
],
[
'code' => 'gu',
'native_name' => 'ગુજરાતી',
],
[
'code' => 'gv',
'native_name' => 'Gaelg, Gailck',
],
[
'code' => 'ha',
'name' => 'Hausa',
'code' => 'ha',
'native_name' => '(Hausa) هَوُسَ',
],
['code' => 'he', 'name' => 'Hebrew', 'native_name' => 'עברית'],
[
'code' => 'hi',
'name' => 'Hindi',
'code' => 'he',
'native_name' => 'עברית',
],
[
'code' => 'hi',
'native_name' => 'हिन्दी, हिंदी',
],
[
'code' => 'ho',
'name' => 'Hiri Motu',
'code' => 'ho',
'native_name' => 'Hiri Motu',
],
[
'code' => 'hr',
'name' => 'Croatian',
'native_name' => 'hrvatski jezik',
'code' => 'hr',
'native_name' => 'Hrvatski jezik',
],
[
'code' => 'ht',
'name' => 'Haitian, Haitian Creole',
'code' => 'ht',
'native_name' => 'Kreyòl ayisyen',
],
['code' => 'hu', 'name' => 'Hungarian', 'native_name' => 'magyar'],
['code' => 'hy', 'name' => 'Armenian', 'native_name' => 'Հայերեն'],
['code' => 'hz', 'name' => 'Herero', 'native_name' => 'Otjiherero'],
[
'code' => 'ia',
'name' =>
'Interlingua (International Auxiliary Language Association)',
'code' => 'hu',
'native_name' => 'Magyar',
],
[
'code' => 'hy',
'native_name' => 'Հայերեն',
],
[
'code' => 'hz',
'native_name' => 'Otjiherero',
],
[
'code' => 'ia',
'native_name' => 'Interlingua',
],
[
'code' => 'id',
'name' => 'Indonesian',
'code' => 'id',
'native_name' => 'Bahasa Indonesia',
],
[
'code' => 'ie',
'name' => 'Interlingue, Occidental',
'native_name' =>
'(originally:) Occidental, (after WWII:) Interlingue',
'code' => 'ie',
'native_name' => 'Interlingue, formerly Occidental',
],
[
'code' => 'ig',
'native_name' => 'Asụsụ Igbo',
],
['code' => 'ig', 'name' => 'Igbo', 'native_name' => 'Asụsụ Igbo'],
[
'code' => 'ii',
'name' => 'Sichuan Yi, Nuosu',
'code' => 'ii',
'native_name' => 'ꆈꌠ꒿ Nuosuhxop',
],
[
'code' => 'ik',
'name' => 'Inupiaq',
'code' => 'ik',
'native_name' => 'Iñupiaq, Iñupiatun',
],
['code' => 'io', 'name' => 'Ido', 'native_name' => 'Ido'],
[
'code' => 'is',
'name' => 'Icelandic',
'code' => 'io',
'native_name' => 'Ido',
],
[
'code' => 'is',
'native_name' => 'Íslenska',
],
['code' => 'it', 'name' => 'Italian', 'native_name' => 'Italiano'],
['code' => 'iu', 'name' => 'Inuktitut', 'native_name' => 'ᐃᓄᒃᑎᑐᑦ'],
[
'code' => 'ja',
'name' => 'Japanese',
'code' => 'it',
'native_name' => 'Italiano',
],
[
'code' => 'iu',
'native_name' => 'ᐃᓄᒃᑎᑐᑦ',
],
[
'code' => 'ja',
'native_name' => '日本語 (にほんご)',
],
[
'code' => 'jv',
'name' => 'Javanese',
'code' => 'jv',
'native_name' => 'ꦧꦱꦗꦮ, Basa Jawa',
],
['code' => 'ka', 'name' => 'Georgian', 'native_name' => 'ქართული'],
['code' => 'kg', 'name' => 'Kongo', 'native_name' => 'Kikongo'],
[
'code' => 'ki',
'name' => 'Kikuyu, Gikuyu',
'code' => 'ka',
'native_name' => 'ქართული',
],
[
'code' => 'kg',
'native_name' => 'Kikongo',
],
[
'code' => 'ki',
'native_name' => 'Gĩkũyũ',
],
[
'code' => 'kj',
'name' => 'Kuanyama, Kwanyama',
'code' => 'kj',
'native_name' => 'Kuanyama',
],
['code' => 'kk', 'name' => 'Kazakh', 'native_name' => 'қазақ тілі'],
[
'code' => 'kl',
'name' => 'Kalaallisut, Greenlandic',
'native_name' => 'kalaallisut, kalaallit oqaasii',
'code' => 'kk',
'native_name' => 'қазақ тілі',
],
[
'code' => 'kl',
'native_name' => 'Kalaallisut, kalaallit oqaasii',
],
[
'code' => 'km',
'name' => 'Central Khmer',
'code' => 'km',
'native_name' => 'ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ',
],
['code' => 'kn', 'name' => 'Kannada', 'native_name' => 'ಕನ್ನಡ'],
['code' => 'ko', 'name' => 'Korean', 'native_name' => '한국어'],
['code' => 'kr', 'name' => 'Kanuri', 'native_name' => 'Kanuri'],
[
'code' => 'ks',
'name' => 'Kashmiri',
'code' => 'kn',
'native_name' => 'ಕನ್ನಡ',
],
[
'code' => 'ko',
'native_name' => '한국어',
],
[
'code' => 'kr',
'native_name' => 'Kanuri',
],
[
'code' => 'ks',
'native_name' => 'कश्मीरी, كشميري',
],
[
'code' => 'ku',
'name' => 'Kurdish',
'code' => 'ku',
'native_name' => 'Kurdî, کوردی',
],
['code' => 'kv', 'name' => 'Komi', 'native_name' => 'коми кыв'],
['code' => 'kw', 'name' => 'Cornish', 'native_name' => 'Kernewek'],
[
'code' => 'ky',
'name' => 'Kirghiz, Kyrgyz',
'code' => 'kv',
'native_name' => 'коми кыв',
],
[
'code' => 'kw',
'native_name' => 'Kernewek',
],
[
'code' => 'ky',
'native_name' => 'Кыргызча, Кыргыз тили',
],
[
'code' => 'la',
'name' => 'Latin',
'native_name' => 'latine, lingua latina',
'code' => 'la',
'native_name' => 'Latine, lingua latina',
],
[
'code' => 'lb',
'name' => 'Luxembourgish, Letzeburgesch',
'code' => 'lb',
'native_name' => 'Lëtzebuergesch',
],
['code' => 'lg', 'name' => 'Ganda', 'native_name' => 'Luganda'],
[
'code' => 'li',
'name' => 'Limburgan, Limburger, Limburgish',
'code' => 'lg',
'native_name' => 'Luganda',
],
[
'code' => 'li',
'native_name' => 'Limburgs',
],
['code' => 'ln', 'name' => 'Lingala', 'native_name' => 'Lingála'],
['code' => 'lo', 'name' => 'Lao', 'native_name' => 'ພາສາລາວ'],
[
'code' => 'lt',
'name' => 'Lithuanian',
'native_name' => 'lietuvių kalba',
'code' => 'ln',
'native_name' => 'Lingála',
],
[
'code' => 'lu',
'name' => 'Luba-Katanga',
'code' => 'lo',
'native_name' => 'ພາສາລາວ',
],
[
'code' => 'lt',
'native_name' => 'Lietuvių kalba',
],
[
'code' => 'lu',
'native_name' => 'Kiluba',
],
[
'code' => 'lv',
'name' => 'Latvian',
'native_name' => 'latviešu valoda',
'code' => 'lv',
'native_name' => 'Latviešu valoda',
],
[
'code' => 'mg',
'name' => 'Malagasy',
'native_name' => 'fiteny malagasy',
'code' => 'mg',
'native_name' => 'Fiteny malagasy',
],
[
'code' => 'mh',
'name' => 'Marshallese',
'code' => 'mh',
'native_name' => 'Kajin M̧ajeļ',
],
[
'code' => 'mi',
'name' => 'Maori',
'native_name' => 'te reo Māori',
'code' => 'mi',
'native_name' => 'Te reo Māori',
],
[
'code' => 'mk',
'name' => 'Macedonian',
'code' => 'mk',
'native_name' => 'македонски јазик',
],
['code' => 'ml', 'name' => 'Malayalam', 'native_name' => 'മലയാളം'],
[
'code' => 'mn',
'name' => 'Mongolian',
'code' => 'ml',
'native_name' => 'മലയാളം',
],
[
'code' => 'mn',
'native_name' => 'Монгол хэл',
],
['code' => 'mr', 'name' => 'Marathi', 'native_name' => 'मराठी'],
[
'code' => 'ms',
'name' => 'Malay',
'code' => 'mr',
'native_name' => 'मराठी',
],
[
'code' => 'ms',
'native_name' => 'Bahasa Melayu, بهاس ملايو',
],
['code' => 'mt', 'name' => 'Maltese', 'native_name' => 'Malti'],
['code' => 'my', 'name' => 'Burmese', 'native_name' => 'ဗမာစာ'],
[
'code' => 'na',
'name' => 'Nauru',
'code' => 'mt',
'native_name' => 'Malti',
],
[
'code' => 'my',
'native_name' => 'ဗမာစာ',
],
[
'code' => 'na',
'native_name' => 'Dorerin Naoero',
],
[
'code' => 'nb',
'name' => 'Norwegian Bokmål',
'code' => 'nb',
'native_name' => 'Norsk Bokmål',
],
[
'code' => 'nd',
'name' => 'North Ndebele',
'code' => 'nd',
'native_name' => 'isiNdebele',
],
['code' => 'ne', 'name' => 'Nepali', 'native_name' => 'नेपाली'],
['code' => 'ng', 'name' => 'Ndonga', 'native_name' => 'Owambo'],
[
'code' => 'nl',
'name' => 'Dutch, Flemish',
'code' => 'ne',
'native_name' => 'नेपाली',
],
[
'code' => 'ng',
'native_name' => 'Owambo',
],
[
'code' => 'nl',
'native_name' => 'Nederlands, Vlaams',
],
[
'code' => 'nn',
'name' => 'Norwegian Nynorsk',
'code' => 'nn',
'native_name' => 'Norsk Nynorsk',
],
['code' => 'no', 'name' => 'Norwegian', 'native_name' => 'Norsk'],
[
'code' => 'nr',
'name' => 'South Ndebele',
'code' => 'no',
'native_name' => 'Norsk',
],
[
'code' => 'nr',
'native_name' => 'isiNdebele',
],
[
'code' => 'nv',
'name' => 'Navajo, Navaho',
'code' => 'nv',
'native_name' => 'Diné bizaad',
],
[
'code' => 'ny',
'name' => 'Chichewa, Chewa, Nyanja',
'native_name' => 'chiCheŵa, chinyanja',
'code' => 'ny',
'native_name' => 'Chicheŵa, chinyanja',
],
[
'code' => 'oc',
'native_name' => 'Occitan, lenga d’òc',
],
[
'code' => 'oc',
'name' => 'Occitan',
'native_name' => 'occitan, lenga d’òc',
'code' => 'oj',
'native_name' => 'ᐊᓂᔑᓈᐯᒧᐎᓐ',
],
['code' => 'oj', 'name' => 'Ojibwa', 'native_name' => 'ᐊᓂᔑᓈᐯᒧᐎᓐ'],
[
'code' => 'om',
'name' => 'Oromo',
'code' => 'om',
'native_name' => 'Afaan Oromoo',
],
['code' => 'or', 'name' => 'Oriya', 'native_name' => 'ଓଡ଼ିଆ'],
[
'code' => 'os',
'name' => 'Ossetian, Ossetic',
'code' => 'or',
'native_name' => 'ଓଡ଼ିଆ',
],
[
'code' => 'os',
'native_name' => 'ирон æвзаг',
],
[
'code' => 'pa',
'name' => 'Punjabi, Panjabi',
'code' => 'pa',
'native_name' => 'ਪੰਜਾਬੀ, پنجابی',
],
['code' => 'pi', 'name' => 'Pali', 'native_name' => 'पालि, पाळि'],
[
'code' => 'pl',
'name' => 'Polish',
'code' => 'pi',
'native_name' => 'पालि, पाळि',
],
[
'code' => 'pl',
'native_name' => 'język polski, polszczyzna',
],
[
'code' => 'ps',
'name' => 'Pashto, Pushto',
'code' => 'ps',
'native_name' => 'پښتو',
],
[
'code' => 'pt',
'name' => 'Portuguese',
'code' => 'pt',
'native_name' => 'Português',
],
[
'code' => 'qu',
'name' => 'Quechua',
'code' => 'qu',
'native_name' => 'Runa Simi, Kichwa',
],
[
'code' => 'rm',
'name' => 'Romansh',
'code' => 'rm',
'native_name' => 'Rumantsch Grischun',
],
['code' => 'rn', 'name' => 'Rundi', 'native_name' => 'Ikirundi'],
[
'code' => 'ro',
'name' => 'Romanian, Moldavian, Moldovan',
'code' => 'rn',
'native_name' => 'Ikirundi',
],
[
'code' => 'ro',
'native_name' => 'Română',
],
['code' => 'ru', 'name' => 'Russian', 'native_name' => 'русский'],
[
'code' => 'rw',
'name' => 'Kinyarwanda',
'code' => 'ru',
'native_name' => 'Pусский',
],
[
'code' => 'rw',
'native_name' => 'Ikinyarwanda',
],
[
'code' => 'sa',
'name' => 'Sanskrit',
'code' => 'sa',
'native_name' => 'संस्कृतम्',
],
['code' => 'sc', 'name' => 'Sardinian', 'native_name' => 'sardu'],
[
'code' => 'sd',
'name' => 'Sindhi',
'code' => 'sc',
'native_name' => 'Sardu',
],
[
'code' => 'sd',
'native_name' => 'सिन्धी, سنڌي، سندھی',
],
[
'code' => 'se',
'name' => 'Northern Sami',
'code' => 'se',
'native_name' => 'Davvisámegiella',
],
[
'code' => 'sg',
'name' => 'Sango',
'native_name' => 'yângâ tî sängö',
'code' => 'sg',
'native_name' => 'Yângâ tî sängö',
],
[
'code' => 'si',
'name' => 'Sinhala, Sinhalese',
'code' => 'si',
'native_name' => 'සිංහල',
],
[
'code' => 'sk',
'name' => 'Slovak',
'code' => 'sk',
'native_name' => 'Slovenčina, Slovenský Jazyk',
],
[
'code' => 'sl',
'name' => 'Slovenian',
'code' => 'sl',
'native_name' => 'Slovenski Jezik, Slovenščina',
],
[
'code' => 'sm',
'name' => 'Samoan',
'native_name' => 'gagana fa\'a Samoa',
'code' => 'sm',
'native_name' => "Gagana fa'a Samoa",
],
['code' => 'sn', 'name' => 'Shona', 'native_name' => 'chiShona'],
[
'code' => 'so',
'name' => 'Somali',
'code' => 'sn',
'native_name' => 'chiShona',
],
[
'code' => 'so',
'native_name' => 'Soomaaliga, af Soomaali',
],
['code' => 'sq', 'name' => 'Albanian', 'native_name' => 'Shqip'],
[
'code' => 'sr',
'name' => 'Serbian',
'code' => 'sq',
'native_name' => 'Shqip',
],
[
'code' => 'sr',
'native_name' => 'српски језик',
],
['code' => 'ss', 'name' => 'Swati', 'native_name' => 'SiSwati'],
[
'code' => 'st',
'name' => 'Southern Sotho',
'code' => 'ss',
'native_name' => 'SiSwati',
],
[
'code' => 'st',
'native_name' => 'Sesotho',
],
[
'code' => 'su',
'name' => 'Sundanese',
'code' => 'su',
'native_name' => 'Basa Sunda',
],
['code' => 'sv', 'name' => 'Swedish', 'native_name' => 'Svenska'],
['code' => 'sw', 'name' => 'Swahili', 'native_name' => 'Kiswahili'],
['code' => 'ta', 'name' => 'Tamil', 'native_name' => 'தமிழ்'],
['code' => 'te', 'name' => 'Telugu', 'native_name' => 'తెలుగు'],
[
'code' => 'tg',
'name' => 'Tajik',
'code' => 'sv',
'native_name' => 'Svenska',
],
[
'code' => 'sw',
'native_name' => 'Kiswahili',
],
[
'code' => 'ta',
'native_name' => 'தமிழ்',
],
[
'code' => 'te',
'native_name' => 'తెలుగు',
],
[
'code' => 'tg',
'native_name' => 'тоҷикӣ, toçikī, تاجیکی',
],
['code' => 'th', 'name' => 'Thai', 'native_name' => 'ไทย'],
['code' => 'ti', 'name' => 'Tigrinya', 'native_name' => 'ትግርኛ'],
[
'code' => 'tk',
'name' => 'Turkmen',
'code' => 'th',
'native_name' => 'ไทย',
],
[
'code' => 'ti',
'native_name' => 'ትግርኛ',
],
[
'code' => 'tk',
'native_name' => 'Türkmen, Түркмен',
],
[
'code' => 'tl',
'name' => 'Tagalog',
'code' => 'tl',
'native_name' => 'Wikang Tagalog',
],
['code' => 'tn', 'name' => 'Tswana', 'native_name' => 'Setswana'],
[
'code' => 'to',
'name' => 'Tonga (Tonga Islands)',
'code' => 'tn',
'native_name' => 'Setswana',
],
[
'code' => 'to',
'native_name' => 'Faka Tonga',
],
['code' => 'tr', 'name' => 'Turkish', 'native_name' => 'Türkçe'],
['code' => 'ts', 'name' => 'Tsonga', 'native_name' => 'Xitsonga'],
[
'code' => 'tt',
'name' => 'Tatar',
'code' => 'tr',
'native_name' => 'Türkçe',
],
[
'code' => 'ts',
'native_name' => 'Xitsonga',
],
[
'code' => 'tt',
'native_name' => 'татар теле, tatar tele',
],
['code' => 'tw', 'name' => 'Twi', 'native_name' => 'Twi'],
[
'code' => 'ty',
'name' => 'Tahitian',
'code' => 'tw',
'native_name' => 'Twi',
],
[
'code' => 'ty',
'native_name' => 'Reo Tahiti',
],
[
'code' => 'ug',
'name' => 'Uighur, Uyghur',
'code' => 'ug',
'native_name' => 'ئۇيغۇرچە, Uyghurche',
],
[
'code' => 'uk',
'name' => 'Ukrainian',
'code' => 'uk',
'native_name' => 'Українська',
],
['code' => 'ur', 'name' => 'Urdu', 'native_name' => 'اردو'],
[
'code' => 'uz',
'name' => 'Uzbek',
'code' => 'ur',
'native_name' => 'اردو',
],
[
'code' => 'uz',
'native_name' => 'Oʻzbek, Ўзбек, أۇزبېك',
],
['code' => 've', 'name' => 'Venda', 'native_name' => 'Tshivenḓa'],
[
'code' => 'vi',
'name' => 'Vietnamese',
'code' => 've',
'native_name' => 'Tshivenḓa',
],
[
'code' => 'vi',
'native_name' => 'Tiếng Việt',
],
['code' => 'vo', 'name' => 'Volapük', 'native_name' => 'Volapük'],
['code' => 'wa', 'name' => 'Walloon', 'native_name' => 'Walon'],
['code' => 'wo', 'name' => 'Wolof', 'native_name' => 'Wollof'],
['code' => 'xh', 'name' => 'Xhosa', 'native_name' => 'isiXhosa'],
['code' => 'yi', 'name' => 'Yiddish', 'native_name' => 'ייִדיש'],
['code' => 'yo', 'name' => 'Yoruba', 'native_name' => 'Yorùbá'],
[
'code' => 'za',
'name' => 'Zhuang, Chuang',
'code' => 'vo',
'native_name' => 'Volapük',
],
[
'code' => 'wa',
'native_name' => 'Walon',
],
[
'code' => 'wo',
'native_name' => 'Wollof',
],
[
'code' => 'xh',
'native_name' => 'isiXhosa',
],
[
'code' => 'yi',
'native_name' => 'ייִדיש',
],
[
'code' => 'yo',
'native_name' => 'Yorùbá',
],
[
'code' => 'za',
'native_name' => 'Saɯ cueŋƅ, Saw cuengh',
],
[
'code' => 'zh',
'name' => 'Chinese',
'code' => 'zh',
'native_name' => '中文 (Zhōngwén), 汉语, 漢語',
],
['code' => 'zu', 'name' => 'Zulu', 'native_name' => 'isiZulu'],
[
'code' => 'zu',
'native_name' => 'isiZulu',
],
];
$this->db->table('languages')->insertBatch($data);
foreach ($data as $languageLine) {
$this->db
->table('languages')
->ignore(true)
->insert($languageLine);
}
}
}
<?php
/**
* Class PlatformsSeeder
* Inserts values in platforms table in database
*
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class PlatformSeeder extends Seeder
{
public function run()
{
$data = [
[
'name' => 'apple-podcasts',
'label' => 'Apple Podcasts',
'home_url' => 'https://www.apple.com/itunes/podcasts/',
'submit_url' =>
'https://podcastsconnect.apple.com/my-podcasts/new-feed',
'icon_filename' => 'apple-podcasts.svg',
],
[
'name' => 'blubrry',
'label' => 'Blubrry',
'home_url' => 'https://www.blubrry.com/',
'submit_url' => 'https://www.blubrry.com/addpodcast.php',
'icon_filename' => 'blubrry.svg',
],
[
'name' => 'castbox',
'label' => 'Castbox',
'home_url' => 'https://castbox.fm/',
'submit_url' =>
'https://helpcenter.castbox.fm/portal/kb/articles/submit-my-podcast',
'icon_filename' => 'castbox.svg',
],
[
'name' => 'castro',
'label' => 'Castro',
'home_url' => 'http://castro.fm/',
'submit_url' => null,
'icon_filename' => 'castro.svg',
],
[
'name' => 'deezer',
'label' => 'Deezer',
'home_url' => 'https://www.deezer.com/',
'submit_url' => 'https://podcasters.deezer.com/submission',
'icon_filename' => 'deezer.svg',
],
[
'name' => 'google-podcasts',
'label' => 'Google Podcasts',
'home_url' => 'https://podcasts.google.com/about',
'submit_url' =>
'https://search.google.com/search-console/about',
'icon_filename' => 'google-podcasts.svg',
],
[
'name' => 'ivoox',
'label' => 'Ivoox',
'home_url' => 'https://www.ivoox.com/',
'submit_url' => null,
'icon_filename' => 'ivoox.svg',
],
[
'name' => 'listennotes',
'label' => 'ListenNotes',
'home_url' => 'https://www.listennotes.com/',
'submit_url' => 'https://www.listennotes.com/submit/',
'icon_filename' => 'listennotes.svg',
],
[
'name' => 'overcast',
'label' => 'Overcast',
'home_url' => 'https://overcast.fm/',
'submit_url' => 'https://overcast.fm/podcasterinfo',
'icon_filename' => 'overcast.svg',
],
[
'name' => 'playerfm',
'label' => 'Player.Fm',
'home_url' => 'https://player.fm/',
'submit_url' => 'https://player.fm/importer/feed',
'icon_filename' => 'playerfm.svg',
],
[
'name' => 'pocketcasts',
'label' => 'Pocketcasts',
'home_url' => 'https://www.pocketcasts.com/',
'submit_url' => 'https://www.pocketcasts.com/submit/',
'icon_filename' => 'pocketcasts.svg',
],
[
'name' => 'podbean',
'label' => 'Podbean',
'home_url' => 'https://www.podbean.com/',
'submit_url' => 'https://www.podbean.com/site/submitPodcast',
'icon_filename' => 'podbean.svg',
],
[
'name' => 'podcast-addict',
'label' => 'Podcast Addict',
'home_url' => 'https://podcastaddict.com/',
'submit_url' => 'https://podcastaddict.com/submit',
'icon_filename' => 'podcast-addict.svg',
],
[
'name' => 'podchaser',
'label' => 'Podchaser',
'home_url' => 'https://www.podchaser.com/',
'submit_url' => 'https://www.podchaser.com/creators/edit',
'icon_filename' => 'podchaser.svg',
],
[
'name' => 'podtail',
'label' => 'Podtail',
'home_url' => 'https://podtail.com/',
'submit_url' => 'https://podtail.com/about/faq/',
'icon_filename' => 'podtail.svg',
],
[
'name' => 'radiopublic',
'label' => 'Radiopublic',
'home_url' => 'https://radiopublic.com/',
'submit_url' => 'https://podcasters.radiopublic.com/signup',
'icon_filename' => 'radiopublic.svg',
],
[
'name' => 'spotify',
'label' => 'Spotify',
'home_url' => 'https://www.spotify.com/',
'submit_url' => 'https://podcasters.spotify.com/submit',
'icon_filename' => 'spotify.svg',
],
[
'name' => 'spreaker',
'label' => 'Spreaker',
'home_url' => 'https://www.spreaker.com/',
'submit_url' => 'https://www.spreaker.com/cms/shows/rss-import',
'icon_filename' => 'spreaker.svg',
],
[
'name' => 'stitcher',
'label' => 'Stitcher',
'home_url' => 'https://www.stitcher.com/',
'submit_url' => 'https://www.stitcher.com/content-providers',
'icon_filename' => 'stitcher.svg',
],
[
'name' => 'tunein',
'label' => 'TuneIn',
'home_url' => 'https://tunein.com/',
'submit_url' =>
'https://help.tunein.com/contact/add-podcast-S19TR3Sdf',
'icon_filename' => 'tunein.svg',
],
];
$this->db->table('platforms')->insertBatch($data);
}
}
<?php
/**
* Class TestSeeder
* Inserts a superadmin user in the database
*
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class TestSeeder extends Seeder
{
public function run()
{
/** Inserts an active user with the following credentials:
* username: admin
* password: AGUehL3P
*/
$this->db->table('users')->insert([
'id' => 1,
'username' => 'admin',
'email' => 'admin@example.com',
'password_hash' =>
'$2y$10$TXJEHX/djW8jtzgpDVf7dOOCGo5rv1uqtAYWdwwwkttQcDkAeB2.6',
'active' => 1,
]);
$this->db
->table('auth_groups_users')
->insert(['group_id' => 1, 'user_id' => 1]);
}
}
<?php
declare(strict_types=1);
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use App\Models\PodcastModel;
use Modules\Fediverse\Entities\Actor as FediverseActor;
use Override;
use RuntimeException;
/**
* @property Podcast|null $podcast
* @property boolean $is_podcast
*/
class Actor extends FediverseActor
{
protected ?Podcast $podcast = null;
protected bool $is_podcast = false;
public function getIsPodcast(): bool
{
return $this->getPodcast() instanceof Podcast;
}
public function getPodcast(): ?Podcast
{
if ($this->id === null) {
throw new RuntimeException('Podcast id must be set before getting associated podcast.');
}
if (! $this->podcast instanceof Podcast) {
$this->podcast = (new PodcastModel())->getPodcastByActorId($this->id);
}
return $this->podcast;
}
#[Override]
public function getAvatarImageUrl(): string
{
if ($this->podcast instanceof Podcast) {
return $this->podcast->cover->thumbnail_url;
}
return parent::getAvatarImageUrl();
}
#[Override]
public function getAvatarImageMimetype(): string
{
if ($this->podcast instanceof Podcast) {
return $this->podcast->cover->thumbnail_mimetype;
}
return parent::getAvatarImageMimetype();
}
}
<?php
/**
* Class AnalyticsEpisodesByPlayer
* Entity for AnalyticsEpisodesByPlayer
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use CodeIgniter\Entity;
class AnalyticsEpisodesByPlayer extends Entity
{
protected $casts = [
'podcast_id' => 'integer',
'episode_id' => 'integer',
'player' => 'string',
'date' => 'datetime',
'hits' => 'integer',
];
}
<?php
/**
* Class AnalyticsPodcastsByCountry
* Entity for AnalyticsPodcastsByCountry
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use CodeIgniter\Entity;
class AnalyticsPodcastsByCountry extends Entity
{
protected $casts = [
'podcast_id' => 'integer',
'country_code' => 'string',
'date' => 'datetime',
'hits' => 'integer',
];
}
<?php
/**
* Class AnalyticsPodcastsByPlayer
* Entity for AnalyticsPodcastsByPlayer
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use CodeIgniter\Entity;
class AnalyticsPodcastsByPlayer extends Entity
{
protected $casts = [
'podcast_id' => 'integer',
'player' => 'string',
'date' => 'datetime',
'hits' => 'integer',
];
}
<?php
/**
* Class AnalyticsWebsiteByBrowser
* Entity for AnalyticsWebsiteByBrowser
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use CodeIgniter\Entity;
class AnalyticsWebsiteByBrowser extends Entity
{
protected $casts = [
'podcast_id' => 'integer',
'browser' => 'string',
'date' => 'datetime',
'hits' => 'integer',
];
}
<?php
/**
* Class AnalyticsWebsiteByCountry
* Entity for AnalyticsWebsiteByCountry
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use CodeIgniter\Entity;
class AnalyticsWebsiteByCountry extends Entity
{
protected $casts = [
'podcast_id' => 'integer',
'country_code' => 'string',
'date' => 'datetime',
'hits' => 'integer',
];
}
<?php
/**
* Class class AnalyticsWebsiteByReferer
* Entity for AnalyticsWebsiteByReferer
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use CodeIgniter\Entity;
class AnalyticsWebsiteByReferer extends Entity
{
protected $casts = [
'podcast_id' => 'integer',
'referer' => 'string',
'date' => 'datetime',
'hits' => 'integer',
];
}
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
......@@ -9,28 +11,37 @@
namespace App\Entities;
use App\Models\CategoryModel;
use CodeIgniter\Entity;
use CodeIgniter\Entity\Entity;
/**
* @property int $id
* @property int $parent_id
* @property Category|null $parent
* @property string $code
* @property string $apple_category
* @property string $google_category
*/
class Category extends Entity
{
protected ?Category $parent = null;
/**
* @var \App\Entity\Category|null
* @var array<string, string>
*/
protected $parent;
protected $casts = [
'parent_id' => 'integer',
'code' => 'string',
'apple_category' => 'string',
'id' => 'integer',
'parent_id' => '?integer',
'code' => 'string',
'apple_category' => 'string',
'google_category' => 'string',
];
public function getParent()
public function getParent(): ?self
{
$parentId = $this->attributes['parent_id'];
if ($this->parent_id === null) {
return null;
}
return $parentId != 0
? (new CategoryModel())->findParent($parentId)
: null;
return (new CategoryModel())->getCategoryById($this->parent_id);
}
}
<?php
declare(strict_types=1);
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities\Clip;
use App\Entities\Episode;
use App\Entities\Podcast;
use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use CodeIgniter\Entity\Entity;
use CodeIgniter\Files\File;
use CodeIgniter\I18n\Time;
use CodeIgniter\Shield\Entities\User;
use Modules\Auth\Models\UserModel;
use Modules\Media\Entities\Audio;
use Modules\Media\Entities\Video;
use Modules\Media\Models\MediaModel;
/**
* @property int $id
* @property int $podcast_id
* @property Podcast $podcast
* @property int $episode_id
* @property Episode $episode
* @property string $title
* @property double $start_time
* @property double $end_time
* @property double $duration
* @property string $type
* @property int|null $media_id
* @property Video|Audio|null $media
* @property array<mixed>|null $metadata
* @property string $status
* @property string $logs
* @property User $user
* @property int $created_by
* @property int $updated_by
* @property Time|null $job_started_at
* @property Time|null $job_ended_at
*/
class BaseClip extends Entity
{
/**
* @var Video|Audio|null
*/
protected $media;
protected ?int $job_duration = null;
protected ?float $end_time = null;
/**
* @var array<int, string>
* @phpstan-var list<string>
*/
protected $dates = ['created_at', 'updated_at', 'job_started_at', 'job_ended_at'];
/**
* @var array<string, string>
*/
protected $casts = [
'id' => 'integer',
'podcast_id' => 'integer',
'episode_id' => 'integer',
'title' => 'string',
'start_time' => 'double',
'duration' => 'double',
'type' => 'string',
'media_id' => '?integer',
'metadata' => '?json-array',
'status' => 'string',
'logs' => 'string',
'created_by' => 'integer',
'updated_by' => 'integer',
];
/**
* @param array<string, mixed>|null $data
*/
public function __construct(?array $data = null)
{
parent::__construct($data);
}
public function getJobDuration(): ?int
{
if ($this->job_duration === null && $this->job_started_at && $this->job_ended_at) {
$this->job_duration = ($this->job_started_at->difference($this->job_ended_at))
->getSeconds();
}
return $this->job_duration;
}
public function getEndTime(): float
{
if ($this->end_time === null) {
$this->end_time = $this->start_time + $this->duration;
}
return $this->end_time;
}
public function getPodcast(): ?Podcast
{
return (new PodcastModel())->getPodcastById($this->podcast_id);
}
public function getEpisode(): ?Episode
{
return (new EpisodeModel())->getEpisodeById($this->episode_id);
}
public function getUser(): ?User
{
/** @var ?User */
return (new UserModel())->find($this->created_by);
}
public function setMedia(File $file, string $fileKey): static
{
if ($this->media_id !== null) {
$this->getMedia()
->setFile($file);
$this->getMedia()
->updated_by = $this->attributes['updated_by'];
(new MediaModel('audio'))->updateMedia($this->getMedia());
} else {
$media = new Audio([
'file_key' => $fileKey,
'language_code' => $this->getPodcast()
->language_code,
'uploaded_by' => $this->attributes['updated_by'],
'updated_by' => $this->attributes['updated_by'],
]);
$media->setFile($file);
$this->attributes['media_id'] = (new MediaModel())->saveMedia($media);
}
return $this;
}
public function getMedia(): Audio | Video | null
{
if ($this->media_id !== null && $this->media === null) {
$this->media = (new MediaModel($this->type))->getMediaById($this->media_id);
}
return $this->media;
}
}