From 91aed205ddcf2c4737f4521f09fa2507cccc1179 Mon Sep 17 00:00:00 2001 From: akshaykamble270 Date: Thu, 25 Apr 2024 17:11:13 +0530 Subject: [PATCH] Custom modules and composer compatibilty with Drupal 10 --- composer.json | 21 +- composer.lock | 560 +++++++++++++++++- .../custom_serialization.info.yml | 2 +- .../Plugin/views/style/CustomSerializer.php | 97 ++- .../custom/group_country_field/README.md | 1 - .../group_country_field.info.yml | 2 +- .../group_country_field.module | 29 +- .../custom/pb_custom_field/css/admin.css | 156 ++++- .../custom/pb_custom_field/js/homepage.js | 58 ++ .../pb_custom_field/pb_custom_field.info.yml | 2 +- .../pb_custom_field/pb_custom_field.module | 208 +++++-- .../src/AssigncontentStatus.php | 11 +- .../src/ChangeActionStatus.php | 12 +- .../src/ChangeintoArchiveActionStatus.php | 12 +- .../src/ChangeintoPublishActionStatus.php | 12 +- .../src/ChangeintoSMEActionStatus.php | 12 +- .../ChangeintoSeniorEditorActionStatus.php | 12 +- .../src/Plugin/Action/AssigncontentAction.php | 11 +- .../src/Plugin/Action/ChangeToSMEAction.php | 8 +- .../Plugin/Action/ChangedToArchiveAction.php | 9 +- .../Action/ChangedToPublishedAction.php | 8 +- .../Action/ChangedToSeniorEditorAction.php | 8 +- .../Action/MovefrompublishtodraftAction.php | 8 +- .../MovefrompublishtosenioreditorAction.php | 8 +- .../Action/MovefrompublishtosmeAction.php | 8 +- .../pb_custom_form/pb_custom_form.info.yml | 4 +- .../pb_custom_form/pb_custom_form.install | 39 +- .../pb_custom_form.libraries.yml | 2 +- .../pb_custom_form/pb_custom_form.module | 205 ++----- .../pb_custom_form/pb_custom_form.routing.yml | 2 +- .../src/ApplyNodeTranslations.php | 169 +++--- .../pb_custom_form/src/ChangeNodeStatus.php | 3 +- .../Controller/ForceCountrySaveController.php | 28 +- .../src/Controller/PbMobile.php | 5 +- .../InternalContentNodeRedirect.php | 89 ++- .../Form/ApplyTransRelatedArticlesVideo.php | 17 +- .../pb_custom_form/src/Form/CustomForm.php | 2 +- .../src/Form/ForceUpdateCheckForm.php | 67 ++- .../src/Form/MobileAppShareLinkForm.php | 10 +- .../pb_custom_form/src/Form/SettingsForm.php | 2 +- .../pb_custom_migrate.info.yml | 2 +- .../pb_custom_rest_api.info.yml | 2 +- .../pb_custom_standard_deviation/README.md | 1 - .../pb_custom_standard_deviation.info.yml | 2 +- .../views/style/CustomStandardDeviation.php | 10 +- 45 files changed, 1394 insertions(+), 542 deletions(-) diff --git a/composer.json b/composer.json index c33ec544..8aff2147 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "drupal/acquia_purge": "^1.0-beta3", "drupal/admin_toolbar": "^3.0", "drupal/allowed_languages": "^2.0@alpha", + "drupal/blazy": "^2.22", "drupal/ckeditor_media_embed": "^1.11", "drupal/color": "^1.0", "drupal/config_ignore": "^3.0@beta", @@ -24,11 +25,10 @@ "drupal/core-composer-scaffold": "10.1.5", "drupal/core-project-message": "10.1.5", "drupal/core-recommended": "10.1.5", - "drupal/core-composer-scaffold": "^8.8", - "drupal/csv_serialization": "^2.0", "drupal/date_popup": "^1.1", "drupal/entity": "^1.2", "drupal/entity_share": "^3.0", + "drupal/entity_share_cron": "^3.0", "drupal/features": "^3.8.0", "drupal/feeds": "^3.0@alpha", "drupal/feeds_tamper": "^2.0@beta", @@ -37,11 +37,14 @@ "drupal/group": "^1.3", "drupal/image_style_quality": "^1.4", "drupal/json_field": "^1.0@RC", + "drupal/jsonapi_extras": "^3.24", + "drupal/jsonapi_page_limit": "^1.1", "drupal/lang_dropdown": "^2.0@beta", "drupal/languagefield": "^1.7", "drupal/layout_builder_styles": "^2.0", "drupal/layout_custom_section_classes": "^1.0", "drupal/layout_section_classes": "^1.3", + "drupal/lazy": "^3.12", "drupal/menu_link_attributes": "^1.3", "drupal/menu_per_role": "^1.3", "drupal/metatag": "*", @@ -51,11 +54,6 @@ "drupal/mobile_app_links": "^2.0", "drupal/quickedit": "^1.0", "drupal/rdf": "^2.1", - "drupal/migrate_plus": "^5.1", - "drupal/migrate_source_csv": "^3.4", - "drupal/migrate_tools": "^6.0", - "drupal/migrate_upgrade": "^3.2", - "drupal/mobile_app_links": "^2.0", "drupal/restui": "^1.20", "drupal/seckit": "^2.0", "drupal/security_review": "^2.0", @@ -68,9 +66,6 @@ "drupal/tmgmt": "^1.15", "drupal/tmgmt_deepl": "^2.1", "drupal/tmgmt_google": "^1.1", - "drupal/tamper": "^1.0@alpha", - "drupal/title_length": "^2.0@RC", - "drupal/tmgmt": "^1.12", "drupal/tmgmt_memsource": "^1.13", "drupal/toolbar_menu": "^3.0", "drupal/toolbar_menu_clean": "^1.3", @@ -165,10 +160,8 @@ "patches": { "drupal/core": { "Updated By sortable issue": "https://www.drupal.org/files/issues/2018-12-28/node_revisions_issue-3021671-07.patch", - "TypeError: implode(): Argument must be of type array":"https://www.drupal.org/files/issues/2023-04-12/3353778-implode_argument.patch" - "Media library weight issue css" : "https://www.drupal.org/files/issues/2020-07-01/interdiff_64-67.txt", - "Vocabulary name not shown in View for Anonymous Users": "https://www.drupal.org/files/issues/2021-04-21/taxonomy_vocabulary_view_permission-3114365.patch", - "Updated By sortable issue": "https://www.drupal.org/files/issues/2018-12-28/node_revisions_issue-3021671-07.patch" + "TypeError: implode(): Argument must be of type array":"https://www.drupal.org/files/issues/2023-04-12/3353778-implode_argument.patch", + "View vocabulery permission issue": "https://www.drupal.org/files/issues/2023-10-26/3114365-37.patch" }, "drupal/video_embed_field": { "Fixed the issue -Mapping for Feeds module missing": "https://www.drupal.org/files/issues/2019-09-02/3056385-feeds-mapping-missing-5.patch" diff --git a/composer.lock b/composer.lock index 253a0733..fdd50cf1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f57b238b4d3fb41dff43e4cdd1c98283", + "content-hash": "63f18e1b218bd8502c8ead491bd753ff", "packages": [ { "name": "acquia/drupal-spec-tool", @@ -2027,6 +2027,73 @@ "issues": "https://www.drupal.org/project/issues/allowed_languages" } }, + { + "name": "drupal/blazy", + "version": "2.22.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/blazy.git", + "reference": "8.x-2.22" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/blazy-8.x-2.22.zip", + "reference": "8.x-2.22", + "shasum": "b1d481c41916c5b3944fda74b4d40501792a19e3" + }, + "require": { + "drupal/core": "^8.8 || ^9 || ^10" + }, + "conflict": { + "drupal/csp": "<1.12" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-2.22", + "datestamp": "1699420645", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Gaus Surahman", + "homepage": "https://www.drupal.org/u/gausarts", + "role": "Maintainer" + }, + { + "name": "Contributors", + "homepage": "https://www.drupal.org/node/2663268/committers", + "role": "Contributor" + }, + { + "name": "geek-merlin", + "homepage": "https://www.drupal.org/user/229048" + }, + { + "name": "sun", + "homepage": "https://www.drupal.org/user/54136" + } + ], + "description": "Provides basic bLazy integration for lazy loading and multi-serving images.", + "homepage": "https://drupal.org/project/blazy", + "keywords": [ + "Drupal", + "bLazy", + "lazyload" + ], + "support": { + "source": "https://git.drupalcode.org/project/blazy", + "issues": "https://drupal.org/project/issues/blazy" + } + }, { "name": "drupal/ckeditor", "version": "1.0.2", @@ -3352,6 +3419,119 @@ "source": "https://git.drupalcode.org/project/entity_share" } }, + { + "name": "drupal/entity_share_client", + "version": "3.0.0", + "require": { + "drupal/core": "^9 || ^10", + "drupal/entity_share": "*" + }, + "type": "metapackage", + "extra": { + "drupal": { + "version": "8.x-3.0", + "datestamp": "1681198393", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Grimreaper", + "homepage": "https://www.drupal.org/user/2388214" + }, + { + "name": "ithom", + "homepage": "https://www.drupal.org/user/3175403" + }, + { + "name": "ivan.vujovic", + "homepage": "https://www.drupal.org/user/382945" + }, + { + "name": "yarik.lutsiuk", + "homepage": "https://www.drupal.org/user/3212333" + } + ], + "description": "Provides an UI to share entities.", + "homepage": "https://www.drupal.org/project/entity_share", + "support": { + "source": "https://git.drupalcode.org/project/entity_share" + } + }, + { + "name": "drupal/entity_share_cron", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/entity_share_cron.git", + "reference": "3.0.2" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/entity_share_cron-3.0.2.zip", + "reference": "3.0.2", + "shasum": "296f18e13edfa6163035c18955e886e6d5f17ddf" + }, + "require": { + "drupal/core": "^9 || ^10", + "drupal/entity_share": "^3.0", + "drupal/entity_share_client": "*" + }, + "require-dev": { + "drupal/block_field": "~1.0", + "drupal/dynamic_entity_reference": "~3.0 || ~4.0", + "drupal/field_group": "~3.0", + "drupal/jsonapi_extras": "~3.14", + "drupal/metatag": "~1.0", + "drupal/paragraphs": "~1.0", + "drupal/pathauto": "~1.0" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "3.0.2", + "datestamp": "1679587487", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "dbiscalchin", + "homepage": "https://www.drupal.org/user/3081151" + }, + { + "name": "Grimreaper", + "homepage": "https://www.drupal.org/user/2388214" + }, + { + "name": "ivan.vujovic", + "homepage": "https://www.drupal.org/user/382945" + }, + { + "name": "yarik.lutsiuk", + "homepage": "https://www.drupal.org/user/3212333" + } + ], + "description": "Synchronizes entities on Cron execution.", + "homepage": "https://www.drupal.org/project/entity_share_cron", + "support": { + "source": "https://git.drupalcode.org/project/entity_share_cron" + } + }, { "name": "drupal/features", "version": "3.13.0", @@ -3671,6 +3851,77 @@ "issues": "https://www.drupal.org/project/issues/filelog" } }, + { + "name": "drupal/google_analytics", + "version": "4.0.2", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/google_analytics.git", + "reference": "4.0.2" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/google_analytics-4.0.2.zip", + "reference": "4.0.2", + "shasum": "6deec511373e4659e42ff494c8729434728e37d7" + }, + "require": { + "drupal/core": "^9.3 || ^10" + }, + "require-dev": { + "drupal/token": "^1.7" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "4.0.2", + "datestamp": "1662768595", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + }, + "branch-alias": { + "dev-4.x": "4.x-dev" + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "See contributors", + "homepage": "https://www.drupal.org/node/49388/committers" + }, + { + "name": "budda", + "homepage": "https://www.drupal.org/user/13164" + }, + { + "name": "ixismark", + "homepage": "https://www.drupal.org/user/3632333" + }, + { + "name": "japerry", + "homepage": "https://www.drupal.org/user/45640" + }, + { + "name": "mglaman", + "homepage": "https://www.drupal.org/user/2416470" + }, + { + "name": "roberto.rivera.ixis", + "homepage": "https://www.drupal.org/user/3632325" + } + ], + "description": "Allows your site to be tracked by Google Analytics by adding a Javascript tracking code to every page.", + "homepage": "https://www.drupal.org/project/google_analytics", + "support": { + "source": "https://git.drupalcode.org/project/google_analytics", + "issues": "https://www.drupal.org/project/issues/google_analytics" + } + }, { "name": "drupal/group", "version": "1.6.0", @@ -3849,6 +4100,121 @@ "issues": "https://www.drupal.org/project/issues/json_field" } }, + { + "name": "drupal/jsonapi_extras", + "version": "3.24.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/jsonapi_extras.git", + "reference": "8.x-3.24" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/jsonapi_extras-8.x-3.24.zip", + "reference": "8.x-3.24", + "shasum": "5031650d17b62f5da5586d3a2c551ac071dbd294" + }, + "require": { + "drupal/core": "^9.2 || ^10", + "e0ipso/shaper": "^1" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-3.24", + "datestamp": "1694442796", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Mateu Aguiló Bosch", + "homepage": "https://www.drupal.org/user/3366066", + "email": "mateu.aguilo.bosch@gmail.com" + }, + { + "name": "Martin Kolar", + "homepage": "https://www.drupal.org/u/mkolar" + }, + { + "name": "Karel Majzlik", + "homepage": "https://www.drupal.org/u/karlos007" + }, + { + "name": "Björn Brala", + "homepage": "https://www.drupal.org/u/bbrala" + } + ], + "description": "JSON:API Extras provides a means to override and provide limited configurations to the default zero-configuration implementation provided by the JSON:API module.", + "homepage": "https://www.drupal.org/project/jsonapi_extras", + "support": { + "source": "https://git.drupalcode.org/project/jsonapi_extras" + } + }, + { + "name": "drupal/jsonapi_page_limit", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/jsonapi_page_limit.git", + "reference": "8.x-1.1" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/jsonapi_page_limit-8.x-1.1.zip", + "reference": "8.x-1.1", + "shasum": "6fa79991a7b34e32e8e021d340f3bae521de63ba" + }, + "require": { + "drupal/core": "^9 || ^10" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-1.1", + "datestamp": "1689290765", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Moshe Weitzman", + "homepage": "https://www.drupal.org/user/3647684", + "email": "weitzman@tejasa.com" + }, + { + "name": "Eli-T", + "homepage": "https://www.drupal.org/user/516878" + }, + { + "name": "Leon Kessler", + "homepage": "https://www.drupal.org/user/595374" + }, + { + "name": "moshe weitzman", + "homepage": "https://www.drupal.org/user/23" + } + ], + "description": "Change the maximum number of items in a response for a given route", + "homepage": "https://www.drupal.org/project/jsonapi_page_limit", + "support": { + "source": "https://git.drupalcode.org/project/jsonapi_page_limit" + } + }, { "name": "drupal/lang_dropdown", "version": "2.1.0", @@ -4129,6 +4495,64 @@ "source": "https://git.drupalcode.org/project/layout_section_classes" } }, + { + "name": "drupal/lazy", + "version": "3.12.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/lazy.git", + "reference": "8.x-3.12" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/lazy-8.x-3.12.zip", + "reference": "8.x-3.12", + "shasum": "c4eae955811f1a152ad582733bae791cfd310d4c" + }, + "require": { + "drupal/core": "^8.8 || ^9.3 || ^10", + "ext-json": "*" + }, + "suggest": { + "bower-asset/lazysizes": "Lazysizes is a required library for the Lazy module. Must be installed to '/libraries/lazysizes' folder." + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-3.12", + "datestamp": "1693453312", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Osman Gormus", + "homepage": "https://www.drupal.org/u/osman", + "role": "Maintainer" + } + ], + "description": "This module enables lazy-loading images and iframes via text-filters and image-fields. Requires lazysizes library.", + "homepage": "https://www.drupal.org/project/lazy", + "keywords": [ + "Drupal", + "Lazy-load", + "bLazy", + "lazy", + "lazyload", + "performance" + ], + "support": { + "source": "https://git.drupalcode.org/project/lazy", + "issues": "https://www.drupal.org/project/issues/lazy" + } + }, { "name": "drupal/memcache", "version": "2.5.0", @@ -6250,33 +6674,33 @@ }, { "name": "drupal/views_bulk_operations", - "version": "4.2.5", + "version": "4.2.6", "source": { "type": "git", "url": "https://git.drupalcode.org/project/views_bulk_operations.git", - "reference": "4.2.5" + "reference": "4.2.6" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/views_bulk_operations-4.2.5.zip", - "reference": "4.2.5", - "shasum": "220479c5187b1619d5703f64c6f8c272afecf897" + "url": "https://ftp.drupal.org/files/projects/views_bulk_operations-4.2.6.zip", + "reference": "4.2.6", + "shasum": "20c6f77c0cebda75edfa570a8dc53fb133d6283a" }, "require": { "drupal/core": "^9.4 || ^10", "php": ">=7.4.0" }, "require-dev": { - "drush/drush": "^11" + "drush/drush": "^12" }, "suggest": { - "drush/drush": "^10 || ^11" + "drush/drush": "^11 || ^12" }, "type": "drupal-module", "extra": { "drupal": { - "version": "4.2.5", - "datestamp": "1691066184", + "version": "4.2.6", + "datestamp": "1704281842", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -6527,6 +6951,52 @@ ], "time": "2023-10-31T14:18:28+00:00" }, + { + "name": "e0ipso/shaper", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/e0ipso/shaper.git", + "reference": "7d73018ec4fe8de9730dfe755067cc02460e1a38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/e0ipso/shaper/zipball/7d73018ec4fe8de9730dfe755067cc02460e1a38", + "reference": "7d73018ec4fe8de9730dfe755067cc02460e1a38", + "shasum": "" + }, + "require": { + "justinrainbow/json-schema": "^5.2" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.4", + "phpunit/phpcov": "^8.2", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Shaper\\": "src", + "Shaper\\Tests\\": "tests/src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0" + ], + "authors": [ + { + "name": "Mateu Aguiló Bosch", + "email": "mateu.aguilo.bosch@gmail.com" + } + ], + "description": "Lightweight library to handle in and out transformations in PHP.", + "support": { + "issues": "https://github.com/e0ipso/shaper/issues", + "source": "https://github.com/e0ipso/shaper/tree/1.2.4" + }, + "time": "2021-05-19T09:42:57+00:00" + }, { "name": "easyrdf/easyrdf", "version": "1.1.1", @@ -7378,6 +7848,76 @@ }, "time": "2022-10-28T13:30:35+00:00" }, + { + "name": "justinrainbow/json-schema", + "version": "v5.2.13", + "source": { + "type": "git", + "url": "https://github.com/justinrainbow/json-schema.git", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/justinrainbow/json-schema/issues", + "source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13" + }, + "time": "2023-09-26T02:20:38+00:00" + }, { "name": "laminas/laminas-escaper", "version": "2.13.0", diff --git a/docroot/modules/custom/custom_serialization/custom_serialization.info.yml b/docroot/modules/custom/custom_serialization/custom_serialization.info.yml index 430495b5..8bec7396 100644 --- a/docroot/modules/custom/custom_serialization/custom_serialization.info.yml +++ b/docroot/modules/custom/custom_serialization/custom_serialization.info.yml @@ -2,4 +2,4 @@ name: PB API Serialization description: Define's a custom serialization package: Custom type: module -core_version_requirement: ^9.2 || ^10 +core_version_requirement: ^9.2 || ^10 || ^11 diff --git a/docroot/modules/custom/custom_serialization/src/Plugin/views/style/CustomSerializer.php b/docroot/modules/custom/custom_serialization/src/Plugin/views/style/CustomSerializer.php index 93a20396..1978cebc 100644 --- a/docroot/modules/custom/custom_serialization/src/Plugin/views/style/CustomSerializer.php +++ b/docroot/modules/custom/custom_serialization/src/Plugin/views/style/CustomSerializer.php @@ -4,11 +4,11 @@ ini_set('serialize_precision', 6); -use Drupal\rest\Plugin\views\style\Serializer; -use Drupal\media\Entity\Media; use Drupal\file\Entity\File; use Drupal\group\Entity\Group; use Drupal\image\Entity\ImageStyle; +use Drupal\media\Entity\Media; +use Drupal\rest\Plugin\views\style\Serializer; /** * The style plugin for serialized output formats. @@ -52,7 +52,7 @@ public function render() { "mandatory", "growth_type", "standard_deviation", "boy_video_article", "girl_video_article", "growth_period", "activity_category", "equipment", "type_of_support", "make_available_for_mobile", "pinned_article", "pinned_video_article", "chatbot_subcategory", - "related_article","old_calendar", + "related_article", "old_calendar", ]; $string_to_array_of_int = [ "related_articles", "keywords", "child_age", "related_activities", "related_video_articles", @@ -163,27 +163,12 @@ public function render() { $rendered_data[$key] = $body_summary; } } - - //dblog after embedded images - \Drupal::logger('custom_serialization')->notice('This is after embedded images with a timestamp: @time', ['@time' => date("Y-m-d H:i:s")]); - /* Custom image & video formattter.To check media image field exist */ - - //dblog before media formatter - \Drupal::logger('custom_serialization')->notice('This is before media formatter with a timestamp: @time', ['@time' => date("Y-m-d H:i:s")]); if (in_array($key, $media_fields)) { $media_formatted_data = $this->customMediaFormatter($key, $values, $language_code); $rendered_data[$key] = $media_formatted_data; } - - //dblog after media formatter - \Drupal::logger('custom_serialization')->notice('This is after media formatter with a timestamp: @time', ['@time' => date("Y-m-d H:i:s")]); - /* Custom array formatter.To check mulitple field. */ - - //dblog before array formatter - \Drupal::logger('custom_serialization')->notice('This is before array formatter with a timestamp: @time', ['@time' => date("Y-m-d H:i:s")]); - if (in_array($key, $array_of_multiple_values)) { $array_formatted_data = $this->customArrayFormatter($values); /* Convert array to array of int. */ @@ -197,9 +182,6 @@ public function render() { } } - //dblog after array formatter - \Drupal::logger('custom_serialization')->notice('This is after array formatter with a timestamp: @time', ['@time' => date("Y-m-d H:i:s")]); - /* Convert string to int. */ if (in_array($key, $string_to_int)) { if (!empty($values)) { @@ -215,7 +197,7 @@ public function render() { /* If the field have comma. */ if (!empty($values) && strpos($values, ',') !== FALSE) { /* remove keywords from taxonomy res */ - if($values != "keywords,Keywords") { + if ($values != "keywords,Keywords") { $formatted_data = explode(',', $values); $vocabulary_name = $formatted_data[1]; $vocabulary_machine_name = $formatted_data[0]; @@ -362,6 +344,7 @@ public function customMediaFormatter($key, $values, $language_code) { if (!empty($values)) { $media_entity = Media::load($values); $media_type = $media_entity->bundle(); + $base_url = \Drupal::request()->getSchemeAndHttpHost(); if ($media_type === 'image') { $mid = $media_entity->get('field_media_image')->target_id; if (!empty($mid)) { @@ -411,11 +394,71 @@ public function customMediaFormatter($key, $values, $language_code) { if ($key == "cover_image") { $tid = $media_entity->get('thumbnail')->target_id; if (!empty($tid)) { - $thumbnail = File::load($tid); - $thumbnail_url = $thumbnail->url(); + if (strpos($media_entity->get('field_media_oembed_video')->value, 'vimeo') !== FALSE) { + // Get the value of the oEmbed video field. + $oembed_value = $media_entity->get('field_media_oembed_video')->value; + + // Parse the oEmbed URL to extract the Vimeo video ID. + $parsed_url = parse_url($oembed_value); + if (isset($parsed_url['path'])) { + // Extract the Vimeo video ID from the path. + $path_segments = explode('/', $parsed_url['path']); + $vimeo_video_id = end($path_segments); + $vimeo_api_url = "https://vimeo.com/api/oembed.json?url=https://vimeo.com/{$vimeo_video_id}"; + + // Initialize cURL session + $ch = curl_init(); + + // Set cURL options + curl_setopt($ch, CURLOPT_URL, $vimeo_api_url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + // Execute the cURL request + $response = curl_exec($ch); + + if ($response === false) { + // cURL error occurred + $error_message = curl_error($ch); + // Handle the error, log it, etc. + $urls ='cURL error'; + } else { + // Close cURL session + curl_close($ch); + + // Decode the JSON response into an associative array + $data = json_decode($response, true); + + if ($data === null) { + // JSON decoding error occurred + $json_error = json_last_error_msg(); + // Handle the error, log it, etc. + $urls ='Vimeo error'; + } else { + // Extract the thumbnail URL from the response data + $urls = isset($data['thumbnail_url']) ? $data['thumbnail_url'] : null; + } + } + } else { + // Vimeo video ID not found in the oEmbed URL + // Handle the error, log it, etc. + $urls ='Vimeo ID not found'; + } + + } + else { + $thumbnail = File::load($tid); + $thumbnail_url = $thumbnail->createFileUrl(); + if (strpos($thumbnail_url, $base_url) !== false) { + // Base URL is present in the thumbnail URL + $urls = $thumbnail_url; + } else { + // Base URL is Not present in the thumbnail URL + $urls = $base_url.$thumbnail_url; + } + } } $media_data = [ - 'url' => $thumbnail_url, + 'url' => $urls, 'name' => $mname, 'alt' => '', ]; @@ -432,7 +475,7 @@ public function customMediaFormatter($key, $values, $language_code) { * @var object */ $file = File::load($mid); - $url = $file->url(); + $url = $file->createFileUrl(); } $media_data = [ @@ -445,7 +488,7 @@ public function customMediaFormatter($key, $values, $language_code) { $tid = $media_entity->get('thumbnail')->target_id; if (!empty($tid)) { $thumbnail = File::load($tid); - $thumbnail_url = $thumbnail->url(); + $thumbnail_url = $thumbnail->createFileUrl(); } $media_data = [ 'url' => $thumbnail_url, diff --git a/docroot/modules/custom/group_country_field/README.md b/docroot/modules/custom/group_country_field/README.md index 08720fa1..d51d6ea7 100644 --- a/docroot/modules/custom/group_country_field/README.md +++ b/docroot/modules/custom/group_country_field/README.md @@ -23,4 +23,3 @@ View: Form ids: Views-exposed-form-tmgmt-translation-all-job-items-page-1 tmgmt-job-item-edit-form - diff --git a/docroot/modules/custom/group_country_field/group_country_field.info.yml b/docroot/modules/custom/group_country_field/group_country_field.info.yml index 5a5bf6be..5fbd1c7c 100644 --- a/docroot/modules/custom/group_country_field/group_country_field.info.yml +++ b/docroot/modules/custom/group_country_field/group_country_field.info.yml @@ -3,4 +3,4 @@ description: Group Country Field Customization type: module package: custom module: group_country_field -core_version_requirement: ^9.2 || ^10 +core_version_requirement: ^9.2 || ^10 || ^11 diff --git a/docroot/modules/custom/group_country_field/group_country_field.module b/docroot/modules/custom/group_country_field/group_country_field.module index 94ade179..271e0784 100644 --- a/docroot/modules/custom/group_country_field/group_country_field.module +++ b/docroot/modules/custom/group_country_field/group_country_field.module @@ -5,9 +5,9 @@ * It contains group field module. */ -use Drupal\views\ViewExecutable; use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\query\QueryPluginBase; +use Drupal\views\ViewExecutable; /** * Implements form alter. @@ -17,19 +17,22 @@ function group_country_field_form_alter(array &$form, FormStateInterface $form_s if ($form['#id'] == "tmgmt-job-item-edit-form") { $user = \Drupal::currentUser(); $user_roles = $user->getRoles(); - $roles_permissions = user_role_permissions($user_roles); - $new_default_state = ["review_after_translation" => "Review_after_translation"]; - if (!empty($roles_permissions['global_admin'])) { - if (in_array("administer nodes", $roles_permissions['global_admin'])) { - $form['moderation_state']['new_state']['#options'] = $form['moderation_state']['new_state']['#options']; + + if(in_array('administrator',$user_roles) !== true) { + $roles_permissions = user_role_permissions($user_roles); + $new_default_state = ["review_after_translation" => "Review_after_translation"]; + if (!empty($roles_permissions['global_admin'])) { + if (in_array("administer nodes", $roles_permissions['global_admin'])) { + $form['moderation_state']['new_state']['#options'] = $form['moderation_state']['new_state']['#options']; + } + } + elseif (!empty($roles_permissions['editor'])) { + $new_default_state = ["review_after_translation" => "Review_after_translation", "draft" => "Draft"]; + $form['moderation_state']['new_state']['#options'] = $new_default_state; + } + else { + $form['moderation_state']['new_state']['#options'] = $new_default_state; } - } - elseif(!empty($roles_permissions['editor'])) { - $new_default_state = ["review_after_translation" => "Review_after_translation","draft" => "Draft"]; - $form['moderation_state']['new_state']['#options'] = $new_default_state; - } - else { - $form['moderation_state']['new_state']['#options'] = $new_default_state; } } } diff --git a/docroot/modules/custom/pb_custom_field/css/admin.css b/docroot/modules/custom/pb_custom_field/css/admin.css index 33ff6a85..743ab917 100644 --- a/docroot/modules/custom/pb_custom_field/css/admin.css +++ b/docroot/modules/custom/pb_custom_field/css/admin.css @@ -340,7 +340,7 @@ height: 20px; } .pb-main-homepage .main-logo .align-center { - width: 50%; + width: 100%; margin: 0; } .pb-main-homepage .region.region-header.headerbg .menu--main { @@ -503,12 +503,12 @@ height: 20px; font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; } img[alt="bebbo-hearts"] { - width: 100px; + width: 50px; text-align: center; - margin-top: 40px; + margin: 20px; } .block-download-applogo .media--type-image { - justify-content: flex-end; + justify-content: flex-start; } .block-download-header { font-size: 30px; @@ -527,9 +527,9 @@ img[alt="bebbo-hearts"] { justify-content: center; } .homepageblock3 { -background: #e8e8e8; + background: #e8e8e8; text-align: center; - padding: 20px; + padding: 60px 20px 20px; } .homepageblock6 p, .homepageblock3 p{ @@ -540,11 +540,11 @@ text-align: center; font-size: 18px; font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; } -.homepageblock6 p:first-child, -.homepageblock3 p:first-child{ -font-size: 24px; -font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; -} +/* .homepageblock6 p:first-child { +/* .homepageblock3 p:first-child{ */ +/* font-size: 24px; */ +/* font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; +} */ .homepageblock4 img { width: 100px; } @@ -572,15 +572,15 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; } .homepageblock5 { background-image: url(/sites/default/files/2023-08/Bebbo%20key%20visual.jpg); - min-height: 500px; + min-height: 300px; background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; - margin-bottom: 20px; + /* margin-bottom: 20px; */ } .featured-bb-image { - width: 200px; + width: 120px; margin: auto; } .head-text { @@ -601,21 +601,22 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; text-align: center; margin-bottom: 30px; } -.layout--twocol-section--67-33 img { - width: 125px +.layout--twocol-section--50-50 img { + width: 75px; + margin-left: 13px; } -.layout--twocol-section--67-33 .menu-item { +.layout--twocol-section--50-50 .menu-item { list-style: none; } -.layout--twocol-section--67-33 .menu-item a{ +.layout--twocol-section--50-50 .menu-item a{ color: white; font-size: 20px; } -.layout--twocol-section--67-33 { +.layout--twocol-section--50-50 { background: #4FA9DD; padding: 30px; } -.layout--twocol-section--67-33 .menu { +.layout--twocol-section--50-50 .menu { display: flex; justify-content: space-around; } @@ -635,13 +636,14 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; } .homepageblock7 { background: #e8e8e8; - padding: 20px; + padding: 30px; font-size: 18px; } .homepageblock7 img{ width: 50px; + margin: 20px; } -.layout--twocol-section--67-33 .menu li a { +.layout--twocol-section--50-50 .menu li a { color: white !important; } .para-img-wrap p{ @@ -669,8 +671,8 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; margin-top: 160px; } -.homepageblock2 .block-download-googlelogo img{ - height: 145px; +.homepageblock2 { + padding-bottom: 30px; } .flx { display: flex; @@ -687,6 +689,54 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; .layout.layout--onecol { margin-top: 100px; } +.menu .menu-item a:hover { + color: #4fa9dd; +} +.menu .menu-item .active { + color: #4fa9dd; +} +.menu .menu-item .is-active { + color: #4fa9dd !important; +} +#features, +#why-bebbo { + scroll-margin-top: 120px; +} +.pb-main-homepage .menu li a { + padding: 0 15px 0 0!important; +} + +.block.block-layout-builder.block-field-blocknodepagetitle { + font-size: 18px; + font-weight: 600; +} + +/* .block-download-applogo img, .block-download-googlelogo img{ + width: 70%; +} */ + +.homepageblock6 { + padding: 60px 20px; +} +.homepageblock6 h2 { + text-align: center; +} +.block-download-googlelogo .align-center { + justify-content: flex-end; +} + +.homepageblock6 .col-md-4 { + padding-left: 35px !important; + padding-right: 35px !important; +} + +.layout-container .progress { + display: block !important; + height: auto !important; + background-color: transparent !important; +} + + /*Homepage css end*/ @media screen and (max-width:767px) @@ -723,6 +773,7 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; /* float: none; width: 95%; */ text-align: center; + font-size: 29px; /* margin:auto ; margin-top: 10px; font-size: 22px; */ @@ -735,7 +786,7 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; width: 92%; } .layout__region--first .media--type-image { - justify-content: center; + justify-content: flex-start; } .pb-main-homepage #block-logo { width: 100% !important; @@ -743,12 +794,13 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; .pb-main-homepage .main-logo { background-color: #f2f2f2; height: 70px; + align-items: center; } .pb-main-homepage .navbar-toggle .icon-bar { background-color: #393636; } .pb-main-homepage .navbar-toggle { - top: 50px; + top: 30px; background: #f4f4f4; } .header-un-logo img { @@ -756,15 +808,63 @@ font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; } .pb-main-homepage .menu li a { padding: 0 !important; + font-size: 13px; } - .layout--twocol-section--67-33 .menu { + .layout--twocol-section--50-50 .menu { margin-top: 20px; } .pb-main-homepage .menu li { list-style: none; - width: 48vw; + width: 42vw; } .homepageblock7 p { width: 100%; } + .header-un-logo img { + margin-left: 16px; + } + .block-download-googlelogo .media--type-image, + .block-download-applogo .media--type-image { + justify-content: center; + } + .homepageblock5 { + min-height: 300px; /* Adjust the height as needed for mobile view */ + background-attachment: scroll; /* Change background attachment for better mobile scrolling */ + } + .block-download-header { + font-size: 22px; + margin-top: 40px; + font-family: "Nunito",Helvetica,Arial,Lucida,sans-serif; + } + .navigation .menu .menu-item { + padding-left: 30px; + } + .navigation .menu .menu-item:first-child { + padding-left: 0px; + } + .navigation .menu .menu-item:last-child { + padding-left: 0px; + } + .homepageblock4 img { + width: 70px; + height: 70px; + } + .img-wrapper-sub2 { + display: flex; + width: 80%; + margin: auto; + justify-content: center; + } + .menu .menu-item a:hover { + color: inherit; + } + +} +@media screen and (min-width: 768px) and (max-width: 950px) { + .pb-main-homepage .menu li a { + font-size: 14px; + } + .pb-main-homepage .main-logo { + font-size: 16px; + } } \ No newline at end of file diff --git a/docroot/modules/custom/pb_custom_field/js/homepage.js b/docroot/modules/custom/pb_custom_field/js/homepage.js index ea56e9d2..422488de 100644 --- a/docroot/modules/custom/pb_custom_field/js/homepage.js +++ b/docroot/modules/custom/pb_custom_field/js/homepage.js @@ -19,5 +19,63 @@ jQuery(document).ready(function() { jQuery('.field--name-field-make-available-for-mobile').nextAll('p').remove(); } +}); + + +jQuery(document).ready(function() { + var menuLinks = jQuery("#block-mainnavigation .menu-item a"); + var scrollOffset = -250; + + jQuery(window).on('scroll', function() { + var currentScroll = jQuery(window).scrollTop(); + + jQuery('.scroll-menu').each(function() { + if (currentScroll >= jQuery(this).position().top + scrollOffset) { + var id = jQuery(this).attr('id'); + menuLinks.removeClass('is-active'); + if (typeof id !== "undefined") { + var correspondingLink = menuLinks.filter('[href="https://www.bebbo.app/#' + id + '"]'); + correspondingLink.addClass('is-active'); + } + } + }); + }); + + menuLinks.on('click', function() { + menuLinks.removeClass('is-active'); + jQuery(this).addClass('is-active'); + }); }); + + +jQuery(document).ready(function() { + var clickTimer = null; + var clickDelay = 10; // Milliseconds delay for double-click emulation + + jQuery("#block-mainnavigation .menu-item").on('click', 'a', function () { + var clickedElement = jQuery(this); + + if (clickTimer === null) { + // First click + clickTimer = setTimeout(function() { + // Single click action + var id = clickedElement.attr('href'); + jQuery('#block-mainnavigation li a.is-active').removeClass("is-active"); + jQuery('#block-mainnavigation .menu-item').find('a[href="'+id+'"]').addClass('is-active'); + + clickTimer = null; // Reset the timer + }, clickDelay); + } else { + // Second click (double click) + clearTimeout(clickTimer); + clickTimer = null; + + // Double click action + // Put your double-click behavior here + } + }); +}); + + + \ No newline at end of file diff --git a/docroot/modules/custom/pb_custom_field/pb_custom_field.info.yml b/docroot/modules/custom/pb_custom_field/pb_custom_field.info.yml index 07cb9d39..711a94a8 100644 --- a/docroot/modules/custom/pb_custom_field/pb_custom_field.info.yml +++ b/docroot/modules/custom/pb_custom_field/pb_custom_field.info.yml @@ -3,4 +3,4 @@ description: Custom Field Customization type: module package: custom module: pb_custom_field -core_version_requirement: ^9.2 || ^10 \ No newline at end of file +core_version_requirement: ^9.2 || ^10 || ^11 diff --git a/docroot/modules/custom/pb_custom_field/pb_custom_field.module b/docroot/modules/custom/pb_custom_field/pb_custom_field.module index 407dc27e..c143a730 100644 --- a/docroot/modules/custom/pb_custom_field/pb_custom_field.module +++ b/docroot/modules/custom/pb_custom_field/pb_custom_field.module @@ -211,7 +211,7 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state } elseif ($path_args[0] == "user" && $path_args[2] == "edit") { $user_id = $path_args[1]; - $user = user_load($user_id); + $user = User::load($user_id); /* get the group details based on logged in user id */ $grp_membership_service = \Drupal::service('group.membership_loader'); $grps = $grp_membership_service->loadByUser($user); @@ -240,6 +240,27 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state } } } + + //target language filter will be have allowed lang. + if($form['#id'] == "views-exposed-form-tmgmt-translation-all-job-items-page-1" || $form['#id'] == "views-exposed-form-tmgmt-job-overview-page-1") { + $user = \Drupal::currentUser(); + $user_roles = $user->getRoles(); + $uid = $user->id(); + $user_lang = \Drupal::service('allowed_languages.allowed_languages_manager')->assignedLanguages(); + if (!in_array('administrator', $user_roles)) { + $alexist_options = $form['target_language']['#options']; + $language_options = []; + $language_options['All'] = "- Any -"; + foreach ($alexist_options as $key => $value) { + if (in_array($key, $user_lang)) { + $language_options[$key] = $value; + } + } + $form['target_language']['#options'] = $language_options; + } + } + + /* Listing page - Language dropdown filter */ if ($form['#id'] == "views-exposed-form-content-listing-page-1" || $form['#id'] == "views-exposed-form-country-content-listing-page-5") { $roles = \Drupal::currentUser()->getRoles(); @@ -247,7 +268,7 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state $groups = Group::loadMultiple(); /* Check the user roles */ if (count(array_intersect($roles, $authorized_roles)) != 0) { - $gids = \Drupal::entityQuery('group')->condition('type', 'country')->execute(); + $gids = \Drupal::entityQuery('group')->accessCheck()->condition('type', 'country')->execute(); $groups = Group::loadMultiple($gids); } $options = ['' => 'All']; @@ -384,7 +405,8 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state if (!in_array($form_language, $clanguage)) { $form['actions']['submit']['#disabled'] = TRUE; $form['actions']['submit']['#access'] = FALSE; - drupal_set_message(t('This content is associated with another language. It cannot be edited.'), 'error'); + \Drupal::messenger()->addError('This content is associated with another language. It cannot be edited.'); + // drupal_set_message(t('.'), 'error'); } else { $form['langcode']['widget'][0]['value']['#options'] = $language_options; @@ -441,7 +463,8 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state if (!in_array($form_language, $clanguage)) { $form['actions']['submit']['#disabled'] = TRUE; $form['actions']['submit']['#access'] = FALSE; - drupal_set_message(t('This content is associated with another language. It cannot be edited.'), 'error'); + \Drupal::messenger()->addError('This content is associated with another language. It cannot be edited.'); + // drupal_set_message(t('.'), 'error'); } else { $form['langcode']['widget'][0]['value']['#options'] = $language_options; @@ -497,10 +520,14 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state $authorized_roles = ['se', 'sme', 'editor']; /* check the country admin check */ if (count(array_intersect($cur_user_roles, $authorized_roles)) != 0) { - $node = $form_state->getFormObject()->getEntity(); - $ntype = $node->getType(); - $ntype = str_replace("_", "-", $ntype); - $chk_type = "node-" . $ntype . "-edit-form"; + $form_object = $form_state->getFormObject(); + $chk_type = ''; + if (($form_object instanceof \Drupal\Core\Entity\EntityFormInterface)) { + $node = $form_object->getEntity(); + $ntype = $node->getType(); + $ntype = str_replace("_", "-", $ntype); + $chk_type = "node-" . $ntype . "-edit-form"; + } if ($form['#id'] == $chk_type) { $user = \Drupal::currentUser(); $uid = $user->id(); @@ -518,9 +545,10 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state $clanguage[] = $mlangval['value']; } if (in_array($form_language, $clanguage)) { - $form['actions']['submit']['#disabled'] = TRUE; - $form['actions']['submit']['#access'] = FALSE; - drupal_set_message(t('This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization.'), 'error'); + // $form['actions']['submit']['#disabled'] = TRUE; + // $form['actions']['submit']['#access'] = FALSE; + // // drupal_set_message(t('This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization.'), 'error'); + // \Drupal::messenger()->addError('This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization.'); } $form['#validate'][] = 'user_access_validation_chk'; $form['actions']['delete']['#access'] = FALSE; @@ -534,7 +562,10 @@ function pb_custom_field_form_alter(array &$form, FormStateInterface $form_state /* Check the user roles */ if (count(array_intersect($cur_user_roles, $authorized_roles)) != 0) { /* get the content type details */ - $node = $form_state->getFormObject()->getEntity(); + $form_object = $form_state->getFormObject(); + if (($form_object instanceof \Drupal\Core\Entity\EntityFormInterface)) { + $node = $form_object->getEntity(); + } /* $node->getType(); $content_type_arr = ['article']; */ @@ -748,7 +779,6 @@ function pb_custom_field_views_pre_view(ViewExecutable $view, $display_id, array $filters['langcode']['value'] = $langarry; $view->display_handler->overrideOption('filters', $filters); } - } /** @@ -882,7 +912,8 @@ function group_user_validate($form, FormStateInterface $form_state) { return TRUE; } else { - drupal_set_message(t('User already added in country.'), 'error'); + // drupal_set_message(t('User already added in country.'), 'error'); + \Drupal::messenger()->addError('User already added in country.'); $form_state->setRebuild(); } } @@ -992,6 +1023,7 @@ function pb_custom_field_views_query_alter(ViewExecutable $view, QueryPluginBase $groups = []; $grp_membership_service = \Drupal::service('group.membership_loader'); $grps = $grp_membership_service->loadByUser($user); + foreach ($grps as $grp) { $groups[] = $grp->getGroup(); } @@ -1015,9 +1047,59 @@ function pb_custom_field_views_query_alter(ViewExecutable $view, QueryPluginBase } } } + if($view->id() =='taxonomy_term' && $view->current_display =='page_2') { + $current_uri = \Drupal::request()->getRequestUri(); + $path_args = explode('/', $current_uri); + if(isset($path_args[3])){ + $db_query = \Drupal::database()->select('node__field_keywords','nd')->fields('nd',['entity_id']); + $orGroup1 = $db_query->condition('nd.field_keywords_target_id', $path_args[3], 'IN'); + $results = $orGroup1->distinct()->execute()->fetchAll(); + //node_field_data.nid + if($query->where[0]['conditions'][0]['value']){ + unset($query->where[0]['conditions'][0]); + } + $ids =[]; + if(!empty($results)) { + foreach($results as $id) { + $ids[] = $id->entity_id; + } + $query->setGroupOperator('OR'); + $query->addWhere(1,'node_field_data.nid', $ids, 'IN'); + } + } + } + + + if ($view->id() == 'tmgmt_translation_all_job_items' && $view->current_display == 'page_1' || $view->id() == 'tmgmt_translation_all_job_items' && $view->current_display == 'block_1') { + $current_user = \Drupal::currentUser(); + $roles = $current_user->getRoles(); + if (!in_array('administrator', $roles)) { + $user_lang = \Drupal::service('allowed_languages.allowed_languages_manager')->assignedLanguages(); + if(!empty($user_lang)) { + $query->setGroupOperator('AND'); + $query->addWhere(1,'tmgmt_job_tmgmt_job_item.target_language', $user_lang, 'IN'); + } + } + } + + if ($view->id() == 'tmgmt_job_overview' && $view->current_display == 'page_1' || $view->id() == 'tmgmt_job_overview' && $view->current_display == 'block_1') { + $current_user = \Drupal::currentUser(); + $roles = $current_user->getRoles(); + if (!in_array('administrator', $roles)) { + $user_lang = \Drupal::service('allowed_languages.allowed_languages_manager')->assignedLanguages(); + if(!empty($user_lang)) { + $query->setGroupOperator('AND'); + $query->addWhere(1,'tmgmt_job.target_language', $user_lang, 'IN'); + } + } + } + + date_default_timezone_set('Asia/Kolkata'); if ($view->id() == 'articles' && ($view->current_display == 'rest_export_5' || $view->current_display == 'rest_export_1' || $view->current_display == 'rest_export_21' || $view->current_display == 'rest_export_3' || $view->current_display == 'rest_export_22' || $view->current_display == 'rest_export_13' || $view->current_display == 'rest_export_2')) { + if(isset($query->where['2'])){ foreach ($query->where['2'] as &$condition_group) { + if(is_array($condition_group)){ foreach ($condition_group as &$condition) { $date = date('Y-m-d H:i'); if($view->current_display == 'rest_export_13'){ @@ -1049,6 +1131,7 @@ function pb_custom_field_views_query_alter(ViewExecutable $view, QueryPluginBase } } } + } } if ($view->id() == 'tmgmt_translation_all_job_items' && $view->current_display == 'page_1') { @@ -1081,9 +1164,10 @@ function pb_custom_field_views_query_alter(ViewExecutable $view, QueryPluginBase $query->addField('', 'tmgmt_job_item.item_id', '', ['function' => 'groupby']); $query->addGroupBy('tmgmt_job_item.item_id'); } - + if ($view->id() == 'tmgmt_translation_all_job_items' && $view->current_display == 'block_1') { $current_user = \Drupal::currentUser(); + $roles = $current_user->getRoles(); if (in_array('editor', $roles)) { $user_lang = \Drupal::service('allowed_languages.allowed_languages_manager')->assignedLanguages(); @@ -1093,6 +1177,7 @@ function pb_custom_field_views_query_alter(ViewExecutable $view, QueryPluginBase } } } + } } //Column sorting converting varchar to numberic @@ -1249,7 +1334,7 @@ function pb_custom_field_preprocess_html(&$variables) { $source_value = $media_entity->getSource()->getSourceFieldValue($media_entity); if ($source_value){ $file_entity = File::load($source_value); - $url = $file_entity->url(); + $url = $file_entity->createFileUrl(); $icon = [ '#tag' => 'link', '#attributes' => [ @@ -1275,7 +1360,7 @@ function pb_custom_field_preprocess_html(&$variables) { $source_value = $media_entity->getSource()->getSourceFieldValue($media_entity); if ($source_value){ $file_entity = File::load($source_value); - $url = $file_entity->url(); + $url = $file_entity->createFileUrl(); $icon = [ '#tag' => 'link', '#attributes' => [ @@ -1311,6 +1396,19 @@ function pb_custom_field_form_user_form_alter(&$form, FormStateInterface $form_s $query = $conn->query("SELECT status FROM users_field_data where uid = '" . $user_id . "'"); $result = $query->fetchObject(); $form['account']['status']['#default_value'] = $result->status; + + if($user_id) { + $database = \Drupal::database(); + $query = $database->select('user__field_receive_content_moderation', 'cm') + ->condition('cm.entity_id', $user_id, '=') + ->fields('cm', ['field_receive_content_moderation_value']); + $result = $query->execute()->fetchAll(); + + if(empty($result)){ + $form['field_receive_content_moderation']['widget']['value']['#default_value'] = true; + } + + } } if ($form_id == "user_form" && in_array("global_admin", $currentUser_roles)) { if (isset($path_args[count($path_args) - 3]) && $path_args[count($path_args) - 3] == "group" && isset($path_args[count($path_args) - 1]) && $path_args[count($path_args) - 1] == "members") { @@ -1341,15 +1439,16 @@ function pb_custom_field_form_user_form_alter(&$form, FormStateInterface $form_s } } elseif ($user_role == "global_admin") { - $form['account']['roles']['#access'] = TRUE; - foreach ($roles as $role) { - if ($role->id() == "authenticated" || $role->id() == "administrator") { - unset($form['account']['roles']['#options'][$role->id()]); - } - if ($role->id() != "global_admin") { - unset($form['account']['roles']['#options'][$role->id()]); - } - } + $form['account']['roles']['#access'] = FALSE; + + // foreach ($roles as $role) { + // if ($role->id() == "authenticated" || $role->id() == "administrator" ) { + // unset($form['account']['roles']['#options'][$role->id()]); + // } + // if ($role->id() != "global_admin") { + // unset($form['account']['roles']['#options'][$role->id()]); + // } + // } } } } @@ -1387,9 +1486,38 @@ function pb_custom_field_form_user_register_form_alter(&$form, &$form_state, $fo */ function pb_custom_field_content_moderation_notification_mail_data_alter(EntityInterface $entity, array &$data) { // Add an extra email address to the list. + //email notification + $all_arry = []; + $all_mail = $data['to']; + + foreach($all_mail as $key => $val) { + if($val) { + $user_load = user_load_by_mail($val); + $uid = $user_load->id(); + $user = User::load($uid); + if($user->get('field_receive_content_moderation')->value == 0) { + $notify = $user->get('field_receive_content_moderation')->value; + } + elseif($user->get('field_receive_content_moderation')->value == 1){ + $notify = $user->get('field_receive_content_moderation')->value; + } + else { + $notify = 'empty'; + } + + if($notify != '0') { + $all_arry[] = $val; + } + } + } + + $data['to'] = $all_arry; global $base_url; - $notification_array = $data['notification']; - $notification_label = end($notification_array); + $notification_label = ''; + if($data['notification']){ + $notification_label = $data['notification']->label; + } + // $notification_label = end($notification_array); // For the master country users mail. if ($notification_label == "Master : Senior Editor Publish" || $notification_label == "Master : Any state to Review_after_translation") { $nid = $data['params']['context']['entity']->nid[0]->value; @@ -1428,9 +1556,12 @@ function pb_custom_field_content_moderation_notification_mail_data_alter(EntityI $uid = $user_load->id(); $user = User::load($uid); $allowe_lng = $user->allowed_languages->getValue(); - $new_array = array_column($allowe_lng, 'target_id'); - if (in_array($node_language, $new_array)) { - $new_arry[] = $mail; + $notify = $user->get('field_receive_content_moderation')->value; + if($notify != '0') { + $new_array = array_column($allowe_lng, 'target_id'); + if (in_array($node_language, $new_array)) { + $new_arry[] = $mail; + } } } } @@ -1460,6 +1591,7 @@ function pb_custom_field_content_moderation_notification_mail_data_alter(EntityI $body_old = str_replace("[node_id]", $nid, $message); $body = str_replace("[link]", $nid_with_link, $body_old); $all_users_email = $data['to']; + if (!empty($all_users_email)) { $new_arry = []; foreach ($all_users_email as $mail) { @@ -1468,14 +1600,18 @@ function pb_custom_field_content_moderation_notification_mail_data_alter(EntityI $uid = $user_load->id(); $user = User::load($uid); $allowe_lng = $user->allowed_languages->getValue(); - $new_array = array_column($allowe_lng, 'target_id'); - if (in_array($node_language, $new_array)) { - $new_arry[] = $mail; + $notify = $user->get('field_receive_content_moderation')->value; + if($notify != '0') { + $new_array = array_column($allowe_lng, 'target_id'); + if (in_array($node_language, $new_array)) { + $new_arry[] = $mail; + } } } } $data['params']['message'] = $body; $data['to'] = $new_arry; + } else { $data['to'] = []; @@ -1591,4 +1727,8 @@ function pb_custom_field_form_submit($form, FormStateInterface $form_state) $user->save(); } } +} + +function pb_custom_field_entity_presave(\Drupal\Core\Entity\EntityInterface $entity) { + } \ No newline at end of file diff --git a/docroot/modules/custom/pb_custom_field/src/AssigncontentStatus.php b/docroot/modules/custom/pb_custom_field/src/AssigncontentStatus.php index a901183f..b196b56d 100644 --- a/docroot/modules/custom/pb_custom_field/src/AssigncontentStatus.php +++ b/docroot/modules/custom/pb_custom_field/src/AssigncontentStatus.php @@ -34,7 +34,7 @@ public static function assignlanguage($n_language, $langoption, &$context) { $same_status_error = 0; foreach ($n_language as $key => $langs) { $current_language = $langs[0]; - $node = node_load($key); + $node = Node::load($key); if (!$node->hasTranslation($langoption)) { $node_lang = $node->getTranslation($current_language); $node_es = $node->addTranslation($langoption, $node_lang->toArray()); @@ -61,11 +61,13 @@ public static function assignlanguage($n_language, $langoption, &$context) { if ($success_msg > 0) { $Succ_message = "Content assigned to country (" . $success_msg . ")
"; - drupal_set_message(t($Succ_message), 'status'); + // drupal_set_message(t($Succ_message), 'status'); + \Drupal::messenger()->addStatus($Succ_message); } if ($same_status_error > 0) { $msg = "Content already exists in country (" . $same_status_error . ")
"; - drupal_set_message(t($msg), 'error'); + // drupal_set_message(t($msg), 'error'); + \Drupal::messenger()->addError($msg); } $context['message'] = $message; $context['results'] = $results; @@ -86,7 +88,8 @@ public static function assignlanguageFinishedCallback($success, $results, $opera } else { $message = t('Finished with an error.'); - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/ChangeActionStatus.php b/docroot/modules/custom/pb_custom_field/src/ChangeActionStatus.php index c76d4135..bcf006e6 100644 --- a/docroot/modules/custom/pb_custom_field/src/ChangeActionStatus.php +++ b/docroot/modules/custom/pb_custom_field/src/ChangeActionStatus.php @@ -91,15 +91,18 @@ public static function offLoadCountryProcessfordraft($n_language, &$context) { } if($success_msg > 0){ $Succ_message = "Content changed into Draft successfully (" . $success_msg . ")"; - drupal_set_message(t($Succ_message), 'status'); + // drupal_set_message(t($Succ_message), 'status'); + \Drupal::messenger()->addStatus($Succ_message); } if($same_status_error > 0){ $msg = "Selected content is already In Draft state (" . $same_status_error . ")"; - drupal_set_message(t($msg), 'error'); + // drupal_set_message(t($msg), 'error'); + \Drupal::messenger()->addError($msg); } if($country_error > 0){ $country_msg = "This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization. (" . $country_error .")"; - drupal_set_message(t($country_msg), 'error'); + // drupal_set_message(t($country_msg), 'error'); + \Drupal::messenger()->addError($country_msg); } $context['message'] = $message; @@ -121,7 +124,8 @@ public static function offLoadsCountryProcessfordraftFinishedCallback($success, } else { $message = t('Finished with an error.'); - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/ChangeintoArchiveActionStatus.php b/docroot/modules/custom/pb_custom_field/src/ChangeintoArchiveActionStatus.php index a2e8244f..d4ecac4f 100644 --- a/docroot/modules/custom/pb_custom_field/src/ChangeintoArchiveActionStatus.php +++ b/docroot/modules/custom/pb_custom_field/src/ChangeintoArchiveActionStatus.php @@ -89,15 +89,18 @@ public static function offLoadCountryProcessd($n_language, &$context) { } if($success_msg > 0){ $Succ_message = "Content Changed into Archive successfully (" . $success_msg . ")"; - drupal_set_message(t($Succ_message), 'status'); + // drupal_set_message(t($Succ_message), 'status'); + \Drupal::messenger()->addStatus($Succ_message); } if($same_status_error > 0){ $msg = "Selected content is already in Archive state (" . $same_status_error . ")"; - drupal_set_message(t($msg), 'error'); + // drupal_set_message(t($msg), 'error'); + \Drupal::messenger()->addError($msg); } if($country_error > 0){ $country_msg = "This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization. (" . $country_error . ")"; - drupal_set_message(t($country_msg), 'error'); + // drupal_set_message(t($country_msg), 'error'); + \Drupal::messenger()->addError($country_msg); } $context['message'] = $message; $context['results'] = $results; @@ -117,7 +120,8 @@ public static function offLoadsCountryProcessFinishedCallback($success, $results } else { $message = t('Finished with an error.'); - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/ChangeintoPublishActionStatus.php b/docroot/modules/custom/pb_custom_field/src/ChangeintoPublishActionStatus.php index 9b3200ad..41c6bce8 100644 --- a/docroot/modules/custom/pb_custom_field/src/ChangeintoPublishActionStatus.php +++ b/docroot/modules/custom/pb_custom_field/src/ChangeintoPublishActionStatus.php @@ -90,15 +90,18 @@ public static function offLoadCountryProcessd($n_language, &$context) { } if($success_msg > 0){ $Succ_message = "Content changed into Published successfully (" . $success_msg . ")"; - drupal_set_message(t($Succ_message), 'status'); + // drupal_set_message(t($Succ_message), 'status'); + \Drupal::messenger()->addStatus($Succ_message); } if($same_status_error > 0){ $msg = "Selected content is already in Published state (" . $same_status_error . ")"; - drupal_set_message(t($msg), 'error'); + // drupal_set_message(t($msg), 'error'); + \Drupal::messenger()->addError($msg); } if($country_error > 0){ $country_msg = "This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization. (" . $country_error . ")"; - drupal_set_message(t($country_msg), 'error'); + // drupal_set_message(t($country_msg), 'error'); + \Drupal::messenger()->addError($country_msg); } $context['message'] = $message; $context['results'] = $results; @@ -118,7 +121,8 @@ public static function offLoadsCountryProcessFinishedCallback($success, $results } else { $message = t('Finished with an error.'); - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/ChangeintoSMEActionStatus.php b/docroot/modules/custom/pb_custom_field/src/ChangeintoSMEActionStatus.php index 70962233..77205542 100644 --- a/docroot/modules/custom/pb_custom_field/src/ChangeintoSMEActionStatus.php +++ b/docroot/modules/custom/pb_custom_field/src/ChangeintoSMEActionStatus.php @@ -91,15 +91,18 @@ public static function smereview($n_language, &$context) { } if($success_msg > 0){ $Succ_message = "Content changed into SME Review successfully (" . $success_msg . ")"; - drupal_set_message(t($Succ_message), 'status'); + // drupal_set_message(t($Succ_message), 'status'); + \Drupal::messenger()->addStatus($Succ_message); } if($same_status_error > 0){ $msg = "Selected content is already in SME Review state (" . $same_status_error . ")"; - drupal_set_message(t($msg), 'error'); + // drupal_set_message(t($msg), 'error'); + \Drupal::messenger()->addError($msg); } if($country_error > 0){ $country_msg = "This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization. (" . $country_error . ")"; - drupal_set_message(t($country_msg), 'error'); + // drupal_set_message(t($country_msg), 'error'); + \Drupal::messenger()->addError($country_msg); } $context['message'] = $message; $context['results'] = $results; @@ -119,7 +122,8 @@ public static function smereviewyProcessFinishedCallback($success, $results, $op } else { $message = t('Finished with an error.'); - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/ChangeintoSeniorEditorActionStatus.php b/docroot/modules/custom/pb_custom_field/src/ChangeintoSeniorEditorActionStatus.php index 0113aa19..cda2b43a 100644 --- a/docroot/modules/custom/pb_custom_field/src/ChangeintoSeniorEditorActionStatus.php +++ b/docroot/modules/custom/pb_custom_field/src/ChangeintoSeniorEditorActionStatus.php @@ -88,15 +88,18 @@ public static function offLoadCountryProcessd($n_language, &$context) { } if($success_msg > 0){ $Succ_message = "Content changed into Senior Editor Review state successfully (" . $success_msg . ")"; - drupal_set_message(t($Succ_message), 'status'); + // drupal_set_message(t($Succ_message), 'status'); + \Drupal::messenger()->addStatus($Succ_message); } if($same_status_error > 0){ $msg = "Selected content is already in Senior Editor Review state (" . $same_status_error . ")"; - drupal_set_message(t($msg), 'error'); + // drupal_set_message(t($msg), 'error'); + \Drupal::messenger()->addError($msg); } if($country_error > 0){ $country_msg = "This content belongs to Master content and cannot be edited. It has to be assigned to your country to allow for further editing and contextualization. (" . $country_error . ")"; - drupal_set_message(t($country_msg), 'error'); + // drupal_set_message(t($country_msg), 'error'); + \Drupal::messenger()->addError($country_msg); } $context['message'] = $message; $context['results'] = $results; @@ -116,7 +119,8 @@ public static function offLoadsCountryProcessFinishedCallback($success, $results } else { $message = t('Finished with an error.'); - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/AssigncontentAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/AssigncontentAction.php index 5d8d2e67..8a2e82e9 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/AssigncontentAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/AssigncontentAction.php @@ -12,6 +12,7 @@ use Drupal\Core\Ajax\HtmlCommand; use Drupal\Core\Ajax\AjaxResponse; use Symfony\Component\HttpFoundation; +use Drupal\node\Entity\Node; /* use Drupal\group\Entity; @@ -182,7 +183,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s */ public function execute(ContentEntityInterface $entity = NULL) { $context = $this->context; - $total_selected = $context{'selected_count'}; + $total_selected = $context['selected_count']; $langoption = $this->configuration['language_option']; $countryoption = $this->configuration['country_option']; $this->processItem = $this->processItem + 1; @@ -191,7 +192,7 @@ public function execute(ContentEntityInterface $entity = NULL) { if (!empty($langoption) && !empty($countryoption)) { $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $node = node_load($nid); + $node = Node::load($nid); $uid = \Drupal::currentUser()->id(); $uname = \Drupal::currentUser()->getDisplayName(); if (!$node->hasTranslation($langoption)) { @@ -237,10 +238,12 @@ public function execute(ContentEntityInterface $entity = NULL) { if ($total_selected == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } return $this->t("Total content selected"); diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangeToSMEAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangeToSMEAction.php index 786540e4..e57e6cec 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangeToSMEAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangeToSMEAction.php @@ -76,7 +76,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -152,10 +152,12 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } // if ($this->initial == 1) { diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToArchiveAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToArchiveAction.php index 921865da..fe6450b8 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToArchiveAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToArchiveAction.php @@ -76,7 +76,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -150,10 +150,13 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); + } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } // if ($this->initial == 1) { diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToPublishedAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToPublishedAction.php index ffc5bd36..347b011d 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToPublishedAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToPublishedAction.php @@ -76,7 +76,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -151,10 +151,12 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } // if ($this->initial == 1) { diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToSeniorEditorAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToSeniorEditorAction.php index 0e30c49c..e336b216 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToSeniorEditorAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/ChangedToSeniorEditorAction.php @@ -77,7 +77,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -151,10 +151,12 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtodraftAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtodraftAction.php index 03424820..ec23280a 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtodraftAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtodraftAction.php @@ -73,7 +73,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -147,10 +147,12 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } // if ($this->initial == 1) { diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosenioreditorAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosenioreditorAction.php index c60b9311..68067cbf 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosenioreditorAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosenioreditorAction.php @@ -71,7 +71,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -156,10 +156,12 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } if ($this->initial == 1) { diff --git a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosmeAction.php b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosmeAction.php index 64f7624a..3e8f7f7f 100644 --- a/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosmeAction.php +++ b/docroot/modules/custom/pb_custom_field/src/Plugin/Action/MovefrompublishtosmeAction.php @@ -73,7 +73,7 @@ public function execute(ContentEntityInterface $entity = NULL) { $error_message = ""; $current_language = $entity->get('langcode')->value; $nid = $entity->get('nid')->getString(); - $archive_node = node_load($nid); + $archive_node = Node::load($nid); $ids = array_column($list, '0'); $all_ids = implode(',', $ids); $node_lang_archive = $archive_node->getTranslation($current_language); @@ -158,10 +158,12 @@ public function execute(ContentEntityInterface $entity = NULL) { /* $message.="Please visit Country content page to view.";*/ if ($list_count == $this->processItem) { if (!empty($message)) { - drupal_set_message($message, 'status'); + // drupal_set_message($message, 'status'); + \Drupal::messenger()->addStatus($message); } if (!empty($error_message)) { - drupal_set_message($error_message, 'error'); + // drupal_set_message($error_message, 'error'); + \Drupal::messenger()->addError($error_message); } } if ($this->initial == 1) { diff --git a/docroot/modules/custom/pb_custom_form/pb_custom_form.info.yml b/docroot/modules/custom/pb_custom_form/pb_custom_form.info.yml index d18f88c2..3f6ecf78 100644 --- a/docroot/modules/custom/pb_custom_form/pb_custom_form.info.yml +++ b/docroot/modules/custom/pb_custom_form/pb_custom_form.info.yml @@ -1,6 +1,6 @@ name: Custom Form -description: Custom form +description: Custom form for Bebbo app type: module package: custom module: pb_custom_form -core_version_requirement: ^9.2 || ^10 +core_version_requirement: ^9.2 || ^10 || ^11 diff --git a/docroot/modules/custom/pb_custom_form/pb_custom_form.install b/docroot/modules/custom/pb_custom_form/pb_custom_form.install index 22cd0e8f..2b5367e7 100644 --- a/docroot/modules/custom/pb_custom_form/pb_custom_form.install +++ b/docroot/modules/custom/pb_custom_form/pb_custom_form.install @@ -1,7 +1,5 @@ 'varchar', 'length' => 255, 'default' => '', 'description' => 'Store current user uuid', - ); + ]; db_add_field('forcefull_check_update_api', 'uuid', $spec); } +/** + * + */ function pb_custom_form_update_70011() { - $spec = array( + $spec = [ 'type' => 'varchar', 'length' => 255, 'default' => '', 'description' => 'Store created at', - ); + ]; db_add_field('forcefull_check_update_api', 'created_at', $spec); } +/** + * + */ function pb_custom_form_update_70012() { - $spec = array( + $spec = [ 'type' => 'varchar', 'length' => 255, 'default' => '', 'description' => 'Store country id', - ); + ]; db_add_field('forcefull_check_update_api', 'countries_id', $spec); } +/** + * + */ function pb_custom_form_update_70013() { - $spec = array( + $spec = [ 'type' => 'varchar', 'length' => 255, 'default' => '', 'description' => 'Store flag status', - ); + ]; db_add_field('forcefull_check_update_api', 'flag_status', $spec); } +/** + * + */ function pb_custom_form_update_70014() { return Database::getConnection() ->schema() @@ -93,6 +106,9 @@ function pb_custom_form_update_70014() { } +/** + * + */ function pb_custom_form_update_70015() { return Database::getConnection() ->schema() @@ -100,6 +116,9 @@ function pb_custom_form_update_70015() { } +/** + * + */ function pb_custom_form_update_70016() { return Database::getConnection() ->schema() diff --git a/docroot/modules/custom/pb_custom_form/pb_custom_form.libraries.yml b/docroot/modules/custom/pb_custom_form/pb_custom_form.libraries.yml index c2af17f9..bc5e3511 100644 --- a/docroot/modules/custom/pb_custom_form/pb_custom_form.libraries.yml +++ b/docroot/modules/custom/pb_custom_form/pb_custom_form.libraries.yml @@ -3,4 +3,4 @@ bootstrap: theme: https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css: {type: external} js: - https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js: {type: external} \ No newline at end of file + https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js: {type: external} diff --git a/docroot/modules/custom/pb_custom_form/pb_custom_form.module b/docroot/modules/custom/pb_custom_form/pb_custom_form.module index a5443fdb..cb1c7da4 100644 --- a/docroot/modules/custom/pb_custom_form/pb_custom_form.module +++ b/docroot/modules/custom/pb_custom_form/pb_custom_form.module @@ -6,8 +6,8 @@ */ use Drupal\Core\Form\FormStateInterface; -use Drupal\views\ViewExecutable; use Drupal\node\NodeInterface; +use Drupal\views\ViewExecutable; /** * Implements hook_theme(). @@ -20,36 +20,36 @@ function pb_custom_form_theme($existing, $type, $theme, $path) { 'variables' => ['app_share_script' => $config->get('mobile_app_share_link')], ], 'kosovo-mobile' => [ - 'variables' => ['kosovo_app_share_script' => $config->get('kosovo_mobile_app_share_link')], - ] + 'variables' => ['kosovo_app_share_script' => $config->get('kosovo_mobile_app_share_link')], + ], ]; } /** * Implements hook_form_alter(). */ -function pb_custom_form_form_alter(&$form, FormStateInterface $form_state, $form_id) { +function pb_custom_form_form_alter(&$form, FormStateInterface $form_state, $form_id) { // Adding custom validation for the welcome page type field. if ($form_id == 'group_country_edit_form') { - ##Make readonly if offload country is enabled + // Make readonly if offload country is enabled. $user = \Drupal::currentUser(); - $roles = $user->getRoles(); + $roles = $user->getRoles(); $global_user = ['global_admin']; if (count(array_intersect($roles, $global_user)) != 0) { if ($form['field_make_available_for_mobile']['widget']['value']['#default_value'] == 1) { $form['field_make_available_for_mobile']['widget']['value']['#disabled'] = 'true'; } - else{ - $form['field_make_available_for_mobile']['widget']['value']['#default_value'] = 'true'; - } - } + else { + $form['field_make_available_for_mobile']['widget']['value']['#default_value'] = 'true'; + } + } /* $form['#attached']['js'][] = drupal_get_path('module', 'pb_custom_field') . '/js/homepage.js'; */ $form['#attached']['library'][] = 'pb_custom_field/mylib'; $form['actions']['submit']['#submit'][] = 'group_country_save'; } - if(strpos($form_id,'edit_form') !== false && strpos($form_id,'node') !== false) { + if (strpos($form_id, 'edit_form') !== FALSE && strpos($form_id, 'node') !== FALSE) { $form['#validate'][] = 'pb_custom_form_node_validate'; } } @@ -62,17 +62,17 @@ function pb_custom_form_node_validate($form, FormStateInterface $form_state) { $user = \Drupal::currentUser(); $roles = $user->getRoles(); - $roles_arr = array ( - 'administrator', - 'global_admin', - ); + $roles_arr = [ + 'administrator', + 'global_admin', + ]; if ($form_state->getValue('moderation_state')[0]['value'] == 'archive') { if (!array_intersect($roles_arr, $roles)) { if (empty($form_state->getValue('revision_log')[0]['value'])) { $form_state->setErrorByName('revision_log', t('Revision log message is required when archiving.')); } - elseif(!empty($form_state->getValue('revision_log')[0]['value']) && strlen(trim($form_state->getValue('revision_log')[0]['value'])) < 3){ + elseif (!empty($form_state->getValue('revision_log')[0]['value']) && strlen(trim($form_state->getValue('revision_log')[0]['value'])) < 3) { $form_state->setErrorByName('revision_log', t('Revision log message is required when archiving.')); } } @@ -122,11 +122,10 @@ function group_country_save($form, FormStateInterface $form_state) { } /** - * Implements hook_preprocess_HOOK() for views_view_field.html.twig + * Implements hook_preprocess_HOOK() for views_view_field.html.twig. */ - -function pb_custom_field_preprocess_views_view_field(&$variables){ - if( $variables['field']->field == 'revision_uid'){ +function pb_custom_field_preprocess_views_view_field(&$variables) { + if ($variables['field']->field == 'revision_uid') { $langcode = $variables['row']->node_field_data_langcode; $nid = $variables['row']->_entity->nid->value; $vid = \Drupal::entityTypeManager()->getStorage('node')->getLatestRevisionId($nid); @@ -148,16 +147,17 @@ function pb_custom_field_preprocess_views_view_field(&$variables){ * Implmenting this hook to avoid duplicate entry of nodes in view. */ function pb_custom_form_views_post_execute(ViewExecutable $view) { - // for chil growth api - - if ($view->id() == 'articles'){ + // For chil growth api. + if ($view->id() == 'articles') { $display_name = $view->getDisplay()->display['id']; switch ($display_name) { - case 'rest_export_18': // Child Growth Pinned Content API - case 'rest_export_20': // Milestone Related Content API + // Child Growth Pinned Content API. + case 'rest_export_18': + // Milestone Related Content API. + case 'rest_export_20': $arrNids = []; $new_result = []; - foreach($view->result as $k => $row) { + foreach ($view->result as $k => $row) { $id = $row->node_field_data_node__field_related_articles_nid; if (!in_array($id, $arrNids)) { $arrNids[] = $id; @@ -167,12 +167,15 @@ function pb_custom_form_views_post_execute(ViewExecutable $view) { $view->result = $new_result; break; - case 'rest_export_17': // Health Check-Ups Pinned Content API - case 'rest_export_1': // FAQ Pinned Content API // api/pinned-contents/en/faq - case 'rest_export_21': // FAQ Updated Pinned Content API // api/updated-pinned-contents/en/faq + // Health Check-Ups Pinned Content API. + case 'rest_export_17': + // FAQ Pinned Content API // api/pinned-contents/en/faq. + case 'rest_export_1': + // FAQ Updated Pinned Content API // api/updated-pinned-contents/en/faq. + case 'rest_export_21': $arrNids = []; $new_result = []; - foreach($view->result as $k => $row) { + foreach ($view->result as $k => $row) { $id = $row->node_field_data_node__field_pinned_article_nid; if (!in_array($id, $arrNids)) { $arrNids[] = $id; @@ -182,10 +185,11 @@ function pb_custom_form_views_post_execute(ViewExecutable $view) { $view->result = $new_result; break; - case 'rest_export_16': // Child Development Girl Pinned Content API // api/pinned-contents/en/child_development/41 + // Child Development Girl Pinned Content API // api/pinned-contents/en/child_development/41. + case 'rest_export_16': $arrNids = []; $new_result = []; - foreach($view->result as $k => $row) { + foreach ($view->result as $k => $row) { $id = $row->node_field_data_node__field_pinned_article_for_girl_nid; if (!in_array($id, $arrNids)) { $arrNids[] = $id; @@ -194,134 +198,35 @@ function pb_custom_form_views_post_execute(ViewExecutable $view) { } $view->result = $new_result; break; - - case 'rest_export_12': //Vaccinations Pinned Content API - // not able to test this as the data is empty - break; - case 'rest_export_19': // Child Development Boy Pinned Content API // api/pinned-contents/en/child_development/40 - $arrNids = []; - $new_result = []; - foreach($view->result as $k => $row) { - $id = $row->node_field_data_node__field_pinned_article_for_boy_nid; - if (!in_array($id, $arrNids)) { - $arrNids[] = $id; - $new_result[] = $row; - } + // Vaccinations Pinned Content API. + case 'rest_export_12': + // Not able to test this as the data is empty. + break; + + // Child Development Boy Pinned Content API // api/pinned-contents/en/child_development/40. + case 'rest_export_19': + $arrNids = []; + $new_result = []; + foreach ($view->result as $k => $row) { + $id = $row->node_field_data_node__field_pinned_article_for_boy_nid; + if (!in_array($id, $arrNids)) { + $arrNids[] = $id; + $new_result[] = $row; } - $view->result = $new_result; - break; + } + $view->result = $new_result; + break; - // case 'rest_export_2': // Article API + // Case 'rest_export_2': // Article API. default: } } } - -function pb_custom_form_cron() { - \Drupal::logger('pb_custom_form')->notice('Cron ran'); -} - /** - * Ultimate cron will call this function, from "ultimate_cron.job.article_api_cron.yml" config file - * Depedency module = ultimate_cron + * */ -function article_api_cache_cron_job() { - $url = \Drupal::request()->getSchemeAndHttpHost(); - - if (isset($_ENV['AH_SITE_ENVIRONMENT'])) { - switch ($_ENV['AH_SITE_ENVIRONMENT']){ - case 'dev': - $domain_name = 'dev.bebbo.app'; - break; - case 'uat': - $domain_name = 'staging.bebbo.app'; - break; - case 'prod': - $domain_name = 'www.bebbo.app'; - break; - } - } - else { - $domain_name = 'dev.bebbo.app'; - } - - //get access token - $access_url = 'https://accounts.acquia.com/api/auth/oauth/token'; - $ac = curl_init($access_url); - curl_setopt($ac, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ac, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($ac, CURLOPT_POSTFIELDS, array('client_id' => '71b253a8-5c37-41de-b349-2e4f489aba6e', - 'client_secret' => 'B1rLfGTncLXtHi6W/I3nYhPMh9bD3xjbSx8m/usnvxU=', - 'grant_type' => 'client_credentials')); - $response_value = curl_exec($ac); - // Get the status code - $status_access = curl_getinfo($ac, CURLINFO_HTTP_CODE); - curl_close($ac); - if($status_access != 200) { - \Drupal::logger('ultimate_cron_article_api')->notice('error in access token status - '.$status_access.' error details-'.$response_value); - } - else { - //cleared cache programmatically. - $result = json_decode($response_value, true); - if(isset($result['access_token'])) { - $token_value = $result['access_token']; - $cache_url = 'https://cloud.acquia.com/api/environments/324529-08c5238f-9d4c-43ce-be88-b3d8e51c7750/domains/'.$domain_name.'/actions/clear-caches'; - $cc = curl_init($cache_url); - curl_setopt($cc, CURLOPT_RETURNTRANSFER, true); - curl_setopt($cc, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($cc, CURLOPT_HTTPHEADER, array( - 'Authorization: Bearer '.$token_value - )); - $ct = curl_exec($cc); - // Get the status code - $status_cache = curl_getinfo($cc, CURLINFO_HTTP_CODE); - curl_close($cc); - if($status_cache != '200' && $status_cache != '202' ) { - \Drupal::logger('ultimate_cron_article_api')->notice('cloud cache not cleared '. $status_cache .' error -'.$ct); - } - else { - \Drupal::logger('ultimate_cron_article_api')->notice('cloud cache cleared '.$status_cache.' Details -'.$ct); - } - } - } - - $langcodes = \Drupal::languageManager()->getLanguages(); - foreach ($langcodes as $key => $value) { - $id = $key; - if (isset($_ENV['AH_SITE_ENVIRONMENT'])) { - switch ($_ENV['AH_SITE_ENVIRONMENT']){ - case 'dev': - $article_api_url = $url.'/api/articles/'.$id.'?category=all'; - break; - case 'test': - $article_api_url = $url.'/api/articles/'.$id.'?category=all'; - break; - case 'prod': - $article_api_url = $url.'/api/articles/'.$id.'?category=all'; - break; - } - } else { - $article_api_url = $url.'/api/articles/'.$id.'?category=all'; - } - - $c = curl_init($article_api_url); - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); - $html = curl_exec($c); - // Get the status code - $status = curl_getinfo($c, CURLINFO_HTTP_CODE); - if($status != 200){ - \Drupal::logger('ultimate_cron_article_api')->notice('There is an error to call an article api for language '.$id.' and error '.$article_api_url); - \Drupal::logger('ultimate_cron_article_api')->notice('error -'.$html); - } else { - \Drupal::logger('ultimate_cron_article_api')->notice('completed article api for language '.$id.' url '. $article_api_url); - } - curl_close($c); - } -} - function pb_custom_form_page_attachments_alter(&$page) { $page['#attached']['library'][] = 'pb_custom_form/bootstrap'; } - diff --git a/docroot/modules/custom/pb_custom_form/pb_custom_form.routing.yml b/docroot/modules/custom/pb_custom_form/pb_custom_form.routing.yml index ff6af85c..844b41e6 100644 --- a/docroot/modules/custom/pb_custom_form/pb_custom_form.routing.yml +++ b/docroot/modules/custom/pb_custom_form/pb_custom_form.routing.yml @@ -84,4 +84,4 @@ pb_custom_form.apply_trans_related_articles_video: requirements: _permission: 'administer site configuration' options: - _admin_route: TRUE \ No newline at end of file + _admin_route: TRUE diff --git a/docroot/modules/custom/pb_custom_form/src/ApplyNodeTranslations.php b/docroot/modules/custom/pb_custom_form/src/ApplyNodeTranslations.php index f90b7851..44e79bc0 100644 --- a/docroot/modules/custom/pb_custom_form/src/ApplyNodeTranslations.php +++ b/docroot/modules/custom/pb_custom_form/src/ApplyNodeTranslations.php @@ -6,30 +6,31 @@ /** * Parses and verifies the doc comments for files. - * */ class ApplyNodeTranslations { - public static function initiateBatchProcessing($type) { - $items = self::getNodeIdsForBatch($type); - - if (empty($items)) { - return; - } - // Start a batch process. - $operation_callback = [ - ['\Drupal\pb_custom_form\ApplyNodeTranslations::operationCallback', [$items]] - ]; - $batch = array( - 'title' => t('Applying related articles and video articles in English content to all translations'), - 'operations' => $operation_callback, - 'finished' => '\Drupal\pb_custom_form\ApplyNodeTranslations::FinishedCallback', - ); - - batch_set($batch); + /** + * + */ + public static function initiateBatchProcessing($type) { + $items = self::getNodeIdsForBatch($type); + + if (empty($items)) { + return; } + // Start a batch process. + $operation_callback = [ + ['\Drupal\pb_custom_form\ApplyNodeTranslations::operationCallback', [$items]], + ]; + $batch = [ + 'title' => t('Applying related articles and video articles in English content to all translations'), + 'operations' => $operation_callback, + 'finished' => '\Drupal\pb_custom_form\ApplyNodeTranslations::FinishedCallback', + ]; + + batch_set($batch); + } - /** * Process callback for the batch set in the TriggerBatchForm form. * @@ -59,68 +60,67 @@ public static function operationCallback(array $items, &$context) { if ($context['sandbox']['progress'] < $context['sandbox']['max']) { // This is a counter that is passed from batch run to batch run. - if (isset($items[$context['sandbox']['progress']])) { - $node = Node::load($items[$context['sandbox']['progress']]); - if(!empty($node->get('field_related_articles')->target_id)) { - $target_ids = $node->get('field_related_articles')->getvalue(); - foreach ($target_ids as $target_id) { - $entity = Node::load($target_id['target_id']); - $translation_nodes = $node->getTranslationLanguages(); - foreach($translation_nodes as $translation_node) { - $lang = $translation_node->getId(); - if ($entity->hasTranslation($lang)) { - $trans_node_target_ids = $node->getTranslation($lang)->field_related_articles->getvalue(); - $trans_target_ids = []; - foreach($trans_node_target_ids as $trans_node_target_id) { - $trans_target_ids[] = $trans_node_target_id['target_id']; - } - if (!in_array($target_id['target_id'], $trans_target_ids)) { - $node->getTranslation($lang)->field_related_articles->appendItem(['target_id' => $target_id['target_id']]); - $node->save(); - } - //unset($trans_target_ids); - } - } - + if (isset($items[$context['sandbox']['progress']])) { + $node = Node::load($items[$context['sandbox']['progress']]); + if (!empty($node->get('field_related_articles')->target_id)) { + $target_ids = $node->get('field_related_articles')->getvalue(); + foreach ($target_ids as $target_id) { + $entity = Node::load($target_id['target_id']); + $translation_nodes = $node->getTranslationLanguages(); + foreach ($translation_nodes as $translation_node) { + $lang = $translation_node->getId(); + if ($entity->hasTranslation($lang)) { + $trans_node_target_ids = $node->getTranslation($lang)->field_related_articles->getvalue(); + $trans_target_ids = []; + foreach ($trans_node_target_ids as $trans_node_target_id) { + $trans_target_ids[] = $trans_node_target_id['target_id']; + } + if (!in_array($target_id['target_id'], $trans_target_ids)) { + $node->getTranslation($lang)->field_related_articles->appendItem(['target_id' => $target_id['target_id']]); + $node->save(); } + // unset($trans_target_ids); + } } - if(!empty($node->get('field_related_video_articles')->target_id)) { - $video_target_ids = $node->get('field_related_video_articles')->getvalue(); - foreach ($video_target_ids as $video_target_id) { - $video_entity = Node::load($video_target_id['target_id']); - $video_translation_nodes = $node->getTranslationLanguages(); - foreach($video_translation_nodes as $video_translation_node) { - $video_lang = $video_translation_node->getId(); - if ($video_entity->hasTranslation($video_lang)) { - $video_trans_node_target_ids = $node->getTranslation($video_lang)->field_related_video_articles->getvalue(); - $video_trans_target_ids = []; - foreach($video_trans_node_target_ids as $video_trans_node_target_id) { - $video_trans_target_ids[] = $video_trans_node_target_id['target_id']; - } - if (!in_array($video_target_id['target_id'], $video_trans_target_ids)) { - $node->getTranslation($video_lang)->field_related_video_articles->appendItem(['target_id' => $video_target_id['target_id']]); - $node->save(); - } - //unset($video_trans_target_ids); - } - } - + + } + } + if (!empty($node->get('field_related_video_articles')->target_id)) { + $video_target_ids = $node->get('field_related_video_articles')->getvalue(); + foreach ($video_target_ids as $video_target_id) { + $video_entity = Node::load($video_target_id['target_id']); + $video_translation_nodes = $node->getTranslationLanguages(); + foreach ($video_translation_nodes as $video_translation_node) { + $video_lang = $video_translation_node->getId(); + if ($video_entity->hasTranslation($video_lang)) { + $video_trans_node_target_ids = $node->getTranslation($video_lang)->field_related_video_articles->getvalue(); + $video_trans_target_ids = []; + foreach ($video_trans_node_target_ids as $video_trans_node_target_id) { + $video_trans_target_ids[] = $video_trans_node_target_id['target_id']; } + if (!in_array($video_target_id['target_id'], $video_trans_target_ids)) { + $node->getTranslation($video_lang)->field_related_video_articles->appendItem(['target_id' => $video_target_id['target_id']]); + $node->save(); + } + // unset($video_trans_target_ids); + } } - $context['message'] = t('[@percentage] Updating "@item" (@id)', [ - '@percentage' => 'Completed ' . ($context['sandbox']['max'] - $context['sandbox']['progress']) .' of ' . $context['sandbox']['max'], - '@item' => $node->label(), - '@id' => 'ID - '. $node->id(), - ]); - + + } } + $context['message'] = t('[@percentage] Updating "@item" (@id)', [ + '@percentage' => 'Completed ' . ($context['sandbox']['max'] - $context['sandbox']['progress']) . ' of ' . $context['sandbox']['max'], + '@item' => $node->label(), + '@id' => 'ID - ' . $node->id(), + ]); - $context['sandbox']['progress']++; - $context['results']['items'][] = $items[$context['sandbox']['progress']]; + } + $context['sandbox']['progress']++; + $context['results']['items'][] = $items[$context['sandbox']['progress']]; // Results are passed to the finished callback. - //$context['results']['items'][] = $items[$context['sandbox']['progress']]; + // $context['results']['items'][] = $items[$context['sandbox']['progress']];. } // When progress equals max, finished is '1' which means completed. Any @@ -129,7 +129,6 @@ public static function operationCallback(array $items, &$context) { $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; } - /** * Batch finished callback. * @@ -157,18 +156,16 @@ public static function finishedCallback($success, array $results, array $operati } } - /** - * Get all nodes from specific content type. - */ - public static function getNodeIdsForBatch($type) { - $nids = db_select('node', 'n') - ->fields('n', array('nid')) - ->condition('type', $type, '=') - ->execute() - ->fetchCol(); - return $nids; - } - + /** + * Get all nodes from specific content type. + */ + public static function getNodeIdsForBatch($type) { + $nids = db_select('node', 'n') + ->fields('n', ['nid']) + ->condition('type', $type, '=') + ->execute() + ->fetchCol(); + return $nids; + } - } diff --git a/docroot/modules/custom/pb_custom_form/src/ChangeNodeStatus.php b/docroot/modules/custom/pb_custom_form/src/ChangeNodeStatus.php index e3b0e479..509b7d3c 100644 --- a/docroot/modules/custom/pb_custom_form/src/ChangeNodeStatus.php +++ b/docroot/modules/custom/pb_custom_form/src/ChangeNodeStatus.php @@ -60,7 +60,8 @@ public static function offLoadCountryProcessFinishedCallback($success, $results, else { $message = t('Finished with an error.'); } - drupal_set_message($message); + // drupal_set_message($message); + \Drupal::messenger()->addMessage($message); } } diff --git a/docroot/modules/custom/pb_custom_form/src/Controller/ForceCountrySaveController.php b/docroot/modules/custom/pb_custom_form/src/Controller/ForceCountrySaveController.php index 23211d77..cc2cac4f 100644 --- a/docroot/modules/custom/pb_custom_form/src/Controller/ForceCountrySaveController.php +++ b/docroot/modules/custom/pb_custom_form/src/Controller/ForceCountrySaveController.php @@ -3,9 +3,9 @@ namespace Drupal\pb_custom_form\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Database\Database; - +use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\user\Entity\User; /** * An pb_custom_form controller. @@ -16,15 +16,15 @@ class ForceCountrySaveController extends ControllerBase { * Returns a render-able array for a test page. */ public function content() { - global $base_url; - - $country_id = \Drupal::request()->query->get('country_id'); - $flag = \Drupal::request()->query->get('flag'); - $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); - $uuid = $user->uuid(); - $date = new DrupalDateTime(); - $conn = Database::getConnection(); - $conn->insert('forcefull_check_update_api')->fields( + global $base_url; + + $country_id = \Drupal::request()->query->get('country_id'); + $flag = \Drupal::request()->query->get('flag'); + $user = User::load(\Drupal::currentUser()->id()); + $uuid = $user->uuid(); + $date = new DrupalDateTime(); + $conn = Database::getConnection(); + $conn->insert('forcefull_check_update_api')->fields( [ 'flag' => $flag, 'country_id' => $country_id, @@ -33,9 +33,9 @@ public function content() { 'created_at' => $date->getTimestamp(), ] )->execute(); - drupal_flush_all_caches(); - $path = $base_url . '/admin/config/parent-buddy/forcefull-update-check'; - my_goto($path); + drupal_flush_all_caches(); + $path = $base_url . '/admin/config/parent-buddy/forcefull-update-check'; + my_goto($path); // $build = [ // '#markup' => 'insert seccefully', diff --git a/docroot/modules/custom/pb_custom_form/src/Controller/PbMobile.php b/docroot/modules/custom/pb_custom_form/src/Controller/PbMobile.php index 00f6af8c..f4f37b8e 100644 --- a/docroot/modules/custom/pb_custom_form/src/Controller/PbMobile.php +++ b/docroot/modules/custom/pb_custom_form/src/Controller/PbMobile.php @@ -15,18 +15,19 @@ class PbMobile extends ControllerBase { * @return array * Return pb-mobile array. */ - public function render($param1,$param2,$param3) { + public function render($param1, $param2, $param3) { return [ '#theme' => 'pb-mobile', ]; } + /** * Display the Kosovo-mobile. * * @return array * Return kosovo-mobile array. */ - public function kosovorender($param1,$param2,$param3) { + public function kosovorender($param1, $param2, $param3) { return [ '#theme' => 'kosovo-mobile', ]; diff --git a/docroot/modules/custom/pb_custom_form/src/EventSubscriber/InternalContentNodeRedirect.php b/docroot/modules/custom/pb_custom_form/src/EventSubscriber/InternalContentNodeRedirect.php index 8470aadd..ab04fc70 100644 --- a/docroot/modules/custom/pb_custom_form/src/EventSubscriber/InternalContentNodeRedirect.php +++ b/docroot/modules/custom/pb_custom_form/src/EventSubscriber/InternalContentNodeRedirect.php @@ -2,20 +2,17 @@ namespace Drupal\pb_custom_form\EventSubscriber; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\RequestEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Core\Language\LanguageManager; +use Drupal\Core\Routing\CurrentRouteMatch; +use Drupal\Core\Routing\TrustedRedirectResponse; use Drupal\Core\Session\AccountProxy; -use Drupal\Core\Routing\Router; -use Drupal\Core\Url; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; -use Drupal\Core\Routing\TrustedRedirectResponse; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\KernelEvents; /** * Event Subscriber for node view redirect. @@ -43,7 +40,6 @@ class InternalContentNodeRedirect implements EventSubscriberInterface { */ protected $currentUser; - /** * Construct method. * @@ -80,57 +76,58 @@ public static function getSubscribedEvents() { /** * {@inheritdoc} */ - public function nodeViewRedirect(\Symfony\Component\HttpKernel\Event\RequestEvent $event) { + public function nodeViewRedirect(RequestEvent $event) { $node = $this->routeMatch->getParameter('node'); global $base_url; $current_path = \Drupal::service('path.current')->getPath(); $internal = \Drupal::service('path_alias.manager')->getAliasByPath($current_path); - $landingPages = ['/homepage', '/about-us','/terms-and-conditions','/privacy-policy', '/foleja', '/foleja-about-us', '/foleja-privacy-policy']; + $landingPages = ['/homepage', '/about-us', '/terms-and-conditions', '/privacy-policy', '/foleja', '/foleja-about-us', '/foleja-privacy-policy']; if (!$this->isNodeRoute()) { return; } - if(in_array($internal, $landingPages)){ + if (in_array($internal, $landingPages)) { return; } if (!$this->currentUser->isAnonymous()) { return; } - + $redirect_urls = [ - 'ru' => 'https://www.unicef.org/eca/ru/bebbo-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B4%D0%BB%D1%8F-%D1%80%D0%BE%D0%B4%D0%B8%D1%82%D0%B5%D0%BB%D0%B5%D0%B9', - 'sq' => 'https://www.unicef.org/albania/sq/bebbo-app-partneri-juaj-n%C3%AB-prind%C3%ABrim', - 'al-sq' => 'https://www.unicef.org/albania/sq/bebbo-app-partneri-juaj-n%C3%AB-prind%C3%ABrim', - 'by-be' => 'https://www.unicef.by/bebbo-belarus/', - 'by-ru' => 'https://www.unicef.by/bebbo-belarus/', - 'bg-bg' => 'https://www.unicef.org/bulgaria/%D0%BD%D0%BE%D0%B2%D0%BE%D1%82%D0%BE-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B1%D0%B5%D0%B1%D0%B1%D0%BE', - 'gr-el' => 'https://www.unicef.org/greece/%CE%B4%CE%B5%CE%BB%CF%84%CE%AF%CE%B1-%CF%84%CF%8D%CF%80%CE%BF%CF%85/h-unicef-%CF%85%CF%80%CE%BF%CE%B4%CE%AD%CF%87%CE%B5%CF%84%CE%B1%CE%B9-%CF%84%CE%B7%CE%BD-%CE%B7%CE%BC%CE%AD%CF%81%CE%B1-%CE%B3%CE%BF%CE%BD%CE%AD%CF%89%CE%BD-%CE%BC%CE%B5-%CE%BC%CE%AF%CE%B1-%CE%BE%CE%B5%CF%87%CF%89%CF%81%CE%B9%CF%83%CF%84%CE%AE-%CE%B5%CE%BA%CE%B4%CE%AE%CE%BB%CF%89%CF%83%CE%B7-%CE%B3%CE%B9%CE%B1-%CF%84%CE%B7%CE%BD-%CF%80%CE%B1%CF%81%CE%BF%CF%85%CF%83%CE%AF%CE%B1%CF%83%CE%B7-%CF%84%CE%B7%CF%82', - 'xk-sq' => 'https://www.bebbo.app/xk-sq/foleja', - 'xk-rs' => 'https://www.bebbo.app/xk-rs/foleja', - 'kg-ky' => 'https://www.unicef.org/kyrgyzstan/ky/%D0%B6%D0%B0%D2%A3%D1%8B-%D0%B1%D0%B5%D0%B1%D0%B1%D0%BE-%D1%82%D0%B8%D1%80%D0%BA%D0%B5%D0%BC%D0%B5%D1%81%D0%B8', - 'kg-ru' => 'https://www.unicef.org/kyrgyzstan/ru/%D0%BD%D0%BE%D0%B2%D0%BE%D0%B5-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B1%D0%B5%D0%B1%D0%B1%D0%BE', - 'me-cnr' => 'https://www.unicef.org/montenegro/price/bebbo-aplikacija-pouzdane-informacije-za-roditelje', - 'mk-mk' => 'https://www.unicef.org/northmacedonia/mk/soop%C5%A1teni%D1%98a/unicef-%D1%98a-pretstavi-aplikaci%D1%98ata-bebbo-za-poddr%C5%A1ka-na-roditelite-i-staratelite-na-deca', - 'mk-sq' => 'https://www.unicef.org/northmacedonia/sq/deklarata-shtypi/unicef-e-shpalosi-aplikacionin-p%C3%ABr-prind%C3%ABrim-bebbo-p%C3%ABr-mb%C3%ABshtetje-t%C3%AB-prind%C3%ABrve-dhe', - 'md-ro' => 'https://www.bebbo.app/ro-ro/homepage', - 'ro' => 'https://www.bebbo.app/ro-ro/homepage', - 'ro-ro' => 'https://www.bebbo.app/ro-ro/homepage', - 'sr' => 'https://www.unicef.org/serbia/bebbo-vas-saputnik-u-roditeljstvu', - 'rs-en' => 'https://www.unicef.org/serbia/en/bebbo-app-your-partner-in-parenthood', - 'rs-sr' => 'https://www.unicef.org/serbia/bebbo-vas-saputnik-u-roditeljstvu', - 'tj-ru' => 'https://bebbo.tj/tj/%d0%b0%d1%81%d0%be%d1%81%d3%a3/', - 'tj-tg' => 'https://bebbo.tj/', - 'uk' => 'https://www.unicef.org/ukraine/press-releases/unicef-launches-bebbo-mobile-app-help-parents-care-children-during-war', - 'uz-ru' => 'https://www.unicef.org/uzbekistan/new-parenting-app-launched', - 'uz-uz' => 'https://www.unicef.org/uzbekistan/uz/new-parenting-app-launched', + 'ru' => 'https://www.unicef.org/eca/ru/bebbo-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B4%D0%BB%D1%8F-%D1%80%D0%BE%D0%B4%D0%B8%D1%82%D0%B5%D0%BB%D0%B5%D0%B9', + 'sq' => 'https://www.unicef.org/albania/sq/bebbo-app-partneri-juaj-n%C3%AB-prind%C3%ABrim', + 'al-sq' => 'https://www.unicef.org/albania/sq/bebbo-app-partneri-juaj-n%C3%AB-prind%C3%ABrim', + 'by-be' => 'https://www.unicef.by/bebbo-belarus/', + 'by-ru' => 'https://www.unicef.by/bebbo-belarus/', + 'bg-bg' => 'https://www.unicef.org/bulgaria/%D0%BD%D0%BE%D0%B2%D0%BE%D1%82%D0%BE-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B1%D0%B5%D0%B1%D0%B1%D0%BE', + 'gr-el' => 'https://www.unicef.org/greece/%CE%B3%CE%BD%CF%89%CF%81%CE%AF%CF%83%CF%84%CE%B5-%CF%84%CE%BF-%CE%B2ebbo', + 'xk-sq' => 'https://www.bebbo.app/xk-sq/foleja', + 'xk-rs' => 'https://www.bebbo.app/xk-rs/foleja', + 'kg-ky' => 'https://www.unicef.org/kyrgyzstan/ky/%D0%B6%D0%B0%D2%A3%D1%8B-%D0%B1%D0%B5%D0%B1%D0%B1%D0%BE-%D1%82%D0%B8%D1%80%D0%BA%D0%B5%D0%BC%D0%B5%D1%81%D0%B8', + 'kg-ru' => 'https://www.unicef.org/kyrgyzstan/ru/%D0%BD%D0%BE%D0%B2%D0%BE%D0%B5-%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B1%D0%B5%D0%B1%D0%B1%D0%BE', + 'me-cnr' => 'https://www.unicef.org/montenegro/price/bebbo-aplikacija-pouzdane-informacije-za-roditelje', + 'mk-mk' => 'https://www.unicef.org/northmacedonia/mk/soop%C5%A1teni%D1%98a/unicef-%D1%98a-pretstavi-aplikaci%D1%98ata-bebbo-za-poddr%C5%A1ka-na-roditelite-i-staratelite-na-deca', + 'mk-sq' => 'https://www.unicef.org/northmacedonia/sq/deklarata-shtypi/unicef-e-shpalosi-aplikacionin-p%C3%ABr-prind%C3%ABrim-bebbo-p%C3%ABr-mb%C3%ABshtetje-t%C3%AB-prind%C3%ABrve-dhe', + 'md-ro' => 'https://www.bebbo.app/ro-ro/homepage', + 'ro' => 'https://www.bebbo.app/ro-ro/homepage', + 'ro-ro' => 'https://www.bebbo.app/ro-ro/homepage', + 'sr' => 'https://www.unicef.org/serbia/bebbo-vas-saputnik-u-roditeljstvu', + 'rs-en' => 'https://www.unicef.org/serbia/en/bebbo-app-your-partner-in-parenthood', + 'rs-sr' => 'https://www.unicef.org/serbia/bebbo-vas-saputnik-u-roditeljstvu', + 'tj-ru' => 'https://bebbo.tj/tj/%d0%b0%d1%81%d0%be%d1%81%d3%a3/', + 'tj-tg' => 'https://bebbo.tj/', + 'uk' => 'https://www.unicef.org/ukraine/press-releases/unicef-launches-bebbo-mobile-app-help-parents-care-children-during-war', + 'uz-ru' => 'https://www.unicef.org/uzbekistan/new-parenting-app-launched', + 'uz-uz' => 'https://www.unicef.org/uzbekistan/uz/new-parenting-app-launched', ]; if (is_numeric($node)) { $node = Node::load($node); } if ($node instanceof NodeInterface) { - $current_lang = \Drupal::languageManager()->getCurrentLanguage()->getId();; - if($current_lang == 'en'){ + $current_lang = \Drupal::languageManager()->getCurrentLanguage()->getId(); + ; + if ($current_lang == 'en') { $path = $base_url . '/'; $event->setResponse(new RedirectResponse($path)); } @@ -143,11 +140,10 @@ public function nodeViewRedirect(\Symfony\Component\HttpKernel\Event\RequestEven $path = $base_url . '/'; $event->setResponse(new RedirectResponse($path)); } - + } \Drupal::service('page_cache_kill_switch')->trigger(); - - + } } @@ -160,4 +156,5 @@ public function nodeViewRedirect(\Symfony\Component\HttpKernel\Event\RequestEven protected function isNodeRoute() { return strpos($this->routeMatch->getRouteName(), 'entity.node.canonical') === 0; } -} \ No newline at end of file + +} diff --git a/docroot/modules/custom/pb_custom_form/src/Form/ApplyTransRelatedArticlesVideo.php b/docroot/modules/custom/pb_custom_form/src/Form/ApplyTransRelatedArticlesVideo.php index 509d183f..8d9a779a 100644 --- a/docroot/modules/custom/pb_custom_form/src/Form/ApplyTransRelatedArticlesVideo.php +++ b/docroot/modules/custom/pb_custom_form/src/Form/ApplyTransRelatedArticlesVideo.php @@ -4,8 +4,6 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Database\Database; -use Drupal\Core\Datetime\DrupalDateTime; use Drupal\pb_custom_form\ApplyNodeTranslations; /** @@ -20,6 +18,9 @@ */ class ApplyTransRelatedArticlesVideo extends FormBase { + /** + * + */ public function getFormId() { return 'apply_trans_related_articles_video'; } @@ -33,14 +34,14 @@ public function getFormId() { * The custom form state. */ public function buildForm(array $form, FormStateInterface $form_state) { - - $content_types=['article'=>'Article', 'video_article'=> 'Video Article']; + + $content_types = ['article' => 'Article', 'video_article' => 'Video Article']; /* Dropdown Select. */ $form['content_types'] = [ '#type' => 'select', '#title' => $this->t('Content type'), '#options' => $content_types, - ]; + ]; /* Add a submit button. */ $form['actions']['submit'] = [ @@ -48,9 +49,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#value' => $this->t('Apply'), '#button_type' => 'primary', ]; - + return $form; } + + /** + * + */ public function submitForm(array &$form, FormStateInterface $form_state) { ApplyNodeTranslations::initiateBatchProcessing($form_state->getValue('content_types')); } diff --git a/docroot/modules/custom/pb_custom_form/src/Form/CustomForm.php b/docroot/modules/custom/pb_custom_form/src/Form/CustomForm.php index b13ada9d..73223b75 100644 --- a/docroot/modules/custom/pb_custom_form/src/Form/CustomForm.php +++ b/docroot/modules/custom/pb_custom_form/src/Form/CustomForm.php @@ -4,8 +4,8 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\group\Entity\Group; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\group\Entity\Group; /* use Drupal\Core\Form\FormBase; diff --git a/docroot/modules/custom/pb_custom_form/src/Form/ForceUpdateCheckForm.php b/docroot/modules/custom/pb_custom_form/src/Form/ForceUpdateCheckForm.php index 05726281..b4afba3b 100644 --- a/docroot/modules/custom/pb_custom_form/src/Form/ForceUpdateCheckForm.php +++ b/docroot/modules/custom/pb_custom_form/src/Form/ForceUpdateCheckForm.php @@ -2,10 +2,11 @@ namespace Drupal\pb_custom_form\Form; -use Drupal\Core\Form\FormBase; -use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Database\Database; use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; +use Drupal\user\Entity\User; /** * Action description. @@ -19,6 +20,9 @@ */ class ForceUpdateCheckForm extends FormBase { + /** + * + */ public function getFormId() { return 'forcefull_check_update'; } @@ -32,14 +36,14 @@ public function getFormId() { * The custom form state. */ public function buildForm(array $form, FormStateInterface $form_state) { - global $base_url; - $country_name = \Drupal::request()->query->get('country_name'); + global $base_url; + $country_name = \Drupal::request()->query->get('country_name'); $form['markup_text'] = [ - '#type' => 'markup', - '#markup' => ' Are you sure you want to proceed with a force update for ' . $country_name . ' Country', + '#type' => 'markup', + '#markup' => ' Are you sure you want to proceed with a force update for ' . $country_name . ' Country', - ]; + ]; $form['actions'] = [ '#type' => 'actions', @@ -51,41 +55,48 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#value' => $this->t('Yes'), '#button_type' => 'primary', ]; - + $form['actions']['submits'] = [ '#type' => 'inline_template', - '#template' => '', -]; + '#template' => '', + ]; return $form; } + + /** + * + */ public function submitForm(array &$form, FormStateInterface $form_state) { global $base_url; - $country_id = \Drupal::request()->query->get('country_id'); - $flag = \Drupal::request()->query->get('flag'); - $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); - $uuid = $user->uuid(); - $date = new DrupalDateTime(); - $conn = Database::getConnection(); - if($flag != '' && $country_id != ''){ - $conn->insert('forcefull_check_update_api')->fields( + $country_id = \Drupal::request()->query->get('country_id'); + $flag = \Drupal::request()->query->get('flag'); + $user = User::load(\Drupal::currentUser()->id()); + $uuid = $user->uuid(); + $date = new DrupalDateTime(); + $conn = Database::getConnection(); + if ($flag != '' && $country_id != '') { + $conn->insert('forcefull_check_update_api')->fields( [ 'flag_status' => $flag, 'countries_id' => $country_id, 'uuid' => $uuid, 'created_at' => $date->getTimestamp(), ] - )->execute(); - drupal_flush_all_caches(); - $path = $base_url . '/admin/config/parent-buddy/forcefull-update-check'; - my_goto($path); - drupal_set_message(t('data inserted successfully'), 'status', TRUE); - }else{ - $path = $base_url . '/admin/config/parent-buddy/forcefull-update-check'; - my_goto($path); - drupal_set_message(t('Please Select Country And Flag'), 'warning', TRUE); - } + )->execute(); + drupal_flush_all_caches(); + $path = $base_url . '/admin/config/parent-buddy/forcefull-update-check'; + my_goto($path); + // drupal_set_message(t('data inserted successfully'), 'status', TRUE);. + \Drupal::messenger()->addStatus('data inserted successfully'); + } + else { + $path = $base_url . '/admin/config/parent-buddy/forcefull-update-check'; + my_goto($path); + // drupal_set_message(t('Please Select Country And Flag'), 'warning', TRUE);. + \Drupal::messenger()->addWarning('Please Select Country And Flag'); + } } } diff --git a/docroot/modules/custom/pb_custom_form/src/Form/MobileAppShareLinkForm.php b/docroot/modules/custom/pb_custom_form/src/Form/MobileAppShareLinkForm.php index a7e11534..ec419198 100644 --- a/docroot/modules/custom/pb_custom_form/src/Form/MobileAppShareLinkForm.php +++ b/docroot/modules/custom/pb_custom_form/src/Form/MobileAppShareLinkForm.php @@ -2,8 +2,8 @@ namespace Drupal\pb_custom_form\Form; -use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * {@inheritdoc} @@ -39,9 +39,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#description' => $this->t('Provide only the content that needs to be embedded with in the script tag here. Donot include script tag.'), '#default_value' => $config->get('mobile_app_share_link'), ]; - /* Kosovo share page - Javascript */ - - $form['kosovo_mobile_app_share_link'] = [ + /* Kosovo share page - Javascript */ + + $form['kosovo_mobile_app_share_link'] = [ '#type' => 'textarea', '#title' => $this->t('Kosovo - Mobile APP Javascript'), '#description' => $this->t('Provide only the content that needs to be embedded with in the script tag here. Donot include script tag.'), @@ -58,7 +58,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $this->config('pb_custom_form.mobile_app_share_link_form') ->set('mobile_app_share_link', $form_state->getValue('mobile_app_share_link')) - ->set('kosovo_mobile_app_share_link', $form_state->getValue('kosovo_mobile_app_share_link')) + ->set('kosovo_mobile_app_share_link', $form_state->getValue('kosovo_mobile_app_share_link')) ->save(); } diff --git a/docroot/modules/custom/pb_custom_form/src/Form/SettingsForm.php b/docroot/modules/custom/pb_custom_form/src/Form/SettingsForm.php index 9ea2ac70..c4ed801b 100644 --- a/docroot/modules/custom/pb_custom_form/src/Form/SettingsForm.php +++ b/docroot/modules/custom/pb_custom_form/src/Form/SettingsForm.php @@ -2,8 +2,8 @@ namespace Drupal\pb_custom_form\Form; -use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * {@inheritdoc} diff --git a/docroot/modules/custom/pb_custom_migrate/pb_custom_migrate.info.yml b/docroot/modules/custom/pb_custom_migrate/pb_custom_migrate.info.yml index e85facf8..f1310327 100644 --- a/docroot/modules/custom/pb_custom_migrate/pb_custom_migrate.info.yml +++ b/docroot/modules/custom/pb_custom_migrate/pb_custom_migrate.info.yml @@ -3,7 +3,7 @@ name: 'PB Custom Migrate (Multilingual)' description: Content multilingual migrations. type: module package: Migration -core_version_requirement: ^9.2 || ^10 +core_version_requirement: ^9.2 || ^10 || ^11 # Dependencies dependencies: diff --git a/docroot/modules/custom/pb_custom_rest_api/pb_custom_rest_api.info.yml b/docroot/modules/custom/pb_custom_rest_api/pb_custom_rest_api.info.yml index de8fbf85..6e783873 100644 --- a/docroot/modules/custom/pb_custom_rest_api/pb_custom_rest_api.info.yml +++ b/docroot/modules/custom/pb_custom_rest_api/pb_custom_rest_api.info.yml @@ -2,4 +2,4 @@ name: Custom REST API description: Define's a Custom REST Resource package: Custom type: module -core_version_requirement: ^9.2 || ^10 +core_version_requirement: ^9.2 || ^10 || ^11 diff --git a/docroot/modules/custom/pb_custom_standard_deviation/README.md b/docroot/modules/custom/pb_custom_standard_deviation/README.md index dda12d79..e014eac4 100644 --- a/docroot/modules/custom/pb_custom_standard_deviation/README.md +++ b/docroot/modules/custom/pb_custom_standard_deviation/README.md @@ -15,4 +15,3 @@ Specific for Parent Buddy Project NOTES ------------ Terms ids are hard coded as the rules are mapped to the same. - diff --git a/docroot/modules/custom/pb_custom_standard_deviation/pb_custom_standard_deviation.info.yml b/docroot/modules/custom/pb_custom_standard_deviation/pb_custom_standard_deviation.info.yml index b73ef3e1..47b79161 100644 --- a/docroot/modules/custom/pb_custom_standard_deviation/pb_custom_standard_deviation.info.yml +++ b/docroot/modules/custom/pb_custom_standard_deviation/pb_custom_standard_deviation.info.yml @@ -2,4 +2,4 @@ name: PB Custom Standard Deviation description: Define's a custom standard deviation package: Custom type: module -core_version_requirement: ^9.2 || ^10 +core_version_requirement: ^9.2 || ^10 || ^11 diff --git a/docroot/modules/custom/pb_custom_standard_deviation/src/Plugin/views/style/CustomStandardDeviation.php b/docroot/modules/custom/pb_custom_standard_deviation/src/Plugin/views/style/CustomStandardDeviation.php index 49333166..9e246079 100644 --- a/docroot/modules/custom/pb_custom_standard_deviation/src/Plugin/views/style/CustomStandardDeviation.php +++ b/docroot/modules/custom/pb_custom_standard_deviation/src/Plugin/views/style/CustomStandardDeviation.php @@ -63,7 +63,7 @@ public function render() { $child_5 = []; for ($i = 0; $i < count($weight_for_height); $i++) { - if(isset($weight_for_height[$i]['child_age'])){ + if (isset($weight_for_height[$i]['child_age'])) { $sorted_weight_for_height = $this->sortChildAgeID($weight_for_height[$i]['child_age']); // \Drupal::logger('pb_custom_standard_deviation')->notice('weight_for_height=>
' . $sorted_weight_for_height . '
'); if ($sorted_weight_for_height === "43,44,45,46") { @@ -122,7 +122,7 @@ function ($elem) { $child_4 = []; $child_5 = []; for ($i = 0; $i <= count($height_for_age); $i++) { - if(isset($height_for_age[$i]['child_age'])){ + if (isset($height_for_age[$i]['child_age'])) { $sorted_height_for_age = $this->sortChildAgeID($height_for_age[$i]['child_age']); // \Drupal::logger('pb_custom_standard_deviation')->notice('height_for_age =>
' . $sorted_height_for_age . '
'); if ($sorted_height_for_age === "43,44,45,46") { @@ -246,11 +246,11 @@ public function checkRequestParams($request_uri) { * To sort child age id. */ public function sortChildAgeID($child_age_id) { - $child_sorted_arr = array(); - $child_age_arr = explode(',',$child_age_id); + $child_sorted_arr = []; + $child_age_arr = explode(',', $child_age_id); sort($child_age_arr); $child_arr_length = count($child_age_arr); - for($x = 0; $x < $child_arr_length; $x++) { + for ($x = 0; $x < $child_arr_length; $x++) { array_push($child_sorted_arr, $child_age_arr[$x]); } $child_age = implode(',', $child_age_arr);