Compare commits
54 Commits
development
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 230f17b5bc | |||
| ef8e3bcfcf | |||
| adf55bc2b2 | |||
| cd8c1826fe | |||
| 0adc05fa2b | |||
| 1c1d168ffb | |||
| 824026ace2 | |||
| 55e47a4913 | |||
| 1b3c70dec6 | |||
| cec5f192c3 | |||
| 554818cc10 | |||
| 65b48b65ba | |||
| 173c868a56 | |||
| 7836522d8a | |||
| 786ce1b14a | |||
| f5fd4ac8da | |||
| 6f67bf97bd | |||
| d947a0e259 | |||
| 334c90fa02 | |||
| bbca20d795 | |||
| 705e2a2eaf | |||
| 61ce28c29e | |||
| efd604808e | |||
| 92efb3b4de | |||
| 6ae4ff9b83 | |||
| f0501d562c | |||
| 4606bec029 | |||
| 91e9a1005a | |||
| f4c4daee05 | |||
| 6696d08607 | |||
| 1150455e43 | |||
| b78609c929 | |||
| 1b40c627e2 | |||
| 3a57ae1584 | |||
| baacbb82a7 | |||
| 493666cabb | |||
| a6be4af9d0 | |||
| bc5976ef1a | |||
| e25846fded | |||
| 466448719b | |||
| 37edd57f85 | |||
| 2df322841e | |||
| 302851abb7 | |||
| ea4e211175 | |||
| 48b2745c42 | |||
| abc73045be | |||
| c244751bb0 | |||
| 6cd06d0aa0 | |||
| 21fde78e08 | |||
| be850dc676 | |||
| 54ea3f46e0 | |||
| 988c3a1ef6 | |||
| 84da84b62d | |||
| 8dc3234bd4 |
@@ -0,0 +1,251 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow
|
||||||
|
# INGROUP: moko-platform.Automation
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
|
# PATH: /.gitea/workflows/branch-protection.yml
|
||||||
|
# BRIEF: Apply standardised branch protection rules to all governed repositories
|
||||||
|
#
|
||||||
|
# +========================================================================+
|
||||||
|
# | BRANCH PROTECTION SETUP |
|
||||||
|
# +========================================================================+
|
||||||
|
# | |
|
||||||
|
# | Applies protection rules for: main, dev, rc, beta, alpha |
|
||||||
|
# | |
|
||||||
|
# | main — Require PR, block rejected reviews, no force push |
|
||||||
|
# | dev — Allow push, no force push, no delete |
|
||||||
|
# | rc — Allow push, no force push, no delete |
|
||||||
|
# | beta — Allow push, no force push, no delete |
|
||||||
|
# | alpha — Allow push, no force push, no delete |
|
||||||
|
# | |
|
||||||
|
# | jmiller has override authority on all branches. |
|
||||||
|
# | |
|
||||||
|
# +========================================================================+
|
||||||
|
|
||||||
|
name: Branch Protection Setup
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 2 * * 1' # Weekly Monday 02:00 UTC
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
dry_run:
|
||||||
|
description: 'Preview mode (no changes)'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
repos:
|
||||||
|
description: 'Comma-separated repo names (empty = all governed repos)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITEA_URL: https://git.mokoconsulting.tech
|
||||||
|
GITEA_ORG: MokoConsulting
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
protect:
|
||||||
|
name: Apply Branch Protection Rules
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Determine target repos
|
||||||
|
id: repos
|
||||||
|
env:
|
||||||
|
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||||
|
run: |
|
||||||
|
API="${GITEA_URL}/api/v1"
|
||||||
|
|
||||||
|
# Platform/standards/infra repos to exclude
|
||||||
|
EXCLUDE="gitea-org-config org-profile gitea-private .mokogitea-private MokoStandards moko-platform MokoTesting"
|
||||||
|
EXCLUDE="$EXCLUDE MokoStandards-Template-Client MokoStandards-Template-Dolibarr MokoStandards-Template-Generic MokoStandards-Template-Joomla MokoDoliProjTemplate"
|
||||||
|
|
||||||
|
if [ -n "${{ inputs.repos }}" ]; then
|
||||||
|
# User-specified repos
|
||||||
|
REPOS=$(echo "${{ inputs.repos }}" | tr ',' ' ')
|
||||||
|
else
|
||||||
|
# Fetch all org repos
|
||||||
|
PAGE=1
|
||||||
|
REPOS=""
|
||||||
|
while true; do
|
||||||
|
BATCH=$(curl -sS \
|
||||||
|
-H "Authorization: token ${GA_TOKEN}" \
|
||||||
|
"${API}/orgs/${GITEA_ORG}/repos?page=${PAGE}&limit=50" \
|
||||||
|
| jq -r '.[].name // empty')
|
||||||
|
[ -z "$BATCH" ] && break
|
||||||
|
REPOS="$REPOS $BATCH"
|
||||||
|
PAGE=$((PAGE + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Filter out excluded repos
|
||||||
|
FILTERED=""
|
||||||
|
for REPO in $REPOS; do
|
||||||
|
SKIP=false
|
||||||
|
for EX in $EXCLUDE; do
|
||||||
|
if [ "$REPO" = "$EX" ]; then
|
||||||
|
SKIP=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$SKIP" = "false" ]; then
|
||||||
|
FILTERED="$FILTERED $REPO"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
REPOS="$FILTERED"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "repos=$REPOS" >> "$GITHUB_OUTPUT"
|
||||||
|
COUNT=$(echo "$REPOS" | wc -w)
|
||||||
|
echo "📋 Target repos (${COUNT}): $REPOS"
|
||||||
|
|
||||||
|
- name: Apply protection rules
|
||||||
|
env:
|
||||||
|
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||||
|
DRY_RUN: ${{ inputs.dry_run || 'false' }}
|
||||||
|
run: |
|
||||||
|
API="${GITEA_URL}/api/v1"
|
||||||
|
REPOS="${{ steps.repos.outputs.repos }}"
|
||||||
|
|
||||||
|
SUCCESS=0
|
||||||
|
FAILED=0
|
||||||
|
SKIPPED=0
|
||||||
|
|
||||||
|
# ── Rule definitions ──────────────────────────────────────
|
||||||
|
# Only the CI bot (jmiller token) can push directly.
|
||||||
|
# All human contributors must use PRs.
|
||||||
|
# Force push disabled on all branches.
|
||||||
|
|
||||||
|
RULE_MAIN='{
|
||||||
|
"rule_name": "main",
|
||||||
|
"enable_push": true,
|
||||||
|
"enable_push_whitelist": true,
|
||||||
|
"push_whitelist_usernames": ["jmiller"],
|
||||||
|
"enable_force_push": false,
|
||||||
|
"enable_force_push_allowlist": false,
|
||||||
|
"force_push_allowlist_usernames": [],
|
||||||
|
"enable_merge_whitelist": false,
|
||||||
|
"required_approvals": 0,
|
||||||
|
"dismiss_stale_approvals": true,
|
||||||
|
"block_on_rejected_reviews": true,
|
||||||
|
"block_on_outdated_branch": false,
|
||||||
|
"priority": 1
|
||||||
|
}'
|
||||||
|
|
||||||
|
RULE_DEV='{
|
||||||
|
"rule_name": "dev",
|
||||||
|
"enable_push": true,
|
||||||
|
"enable_push_whitelist": true,
|
||||||
|
"push_whitelist_usernames": ["jmiller"],
|
||||||
|
"enable_force_push": false,
|
||||||
|
"enable_force_push_allowlist": false,
|
||||||
|
"force_push_allowlist_usernames": [],
|
||||||
|
"enable_merge_whitelist": false,
|
||||||
|
"required_approvals": 0,
|
||||||
|
"block_on_rejected_reviews": false,
|
||||||
|
"priority": 2
|
||||||
|
}'
|
||||||
|
|
||||||
|
RULE_RC='{
|
||||||
|
"rule_name": "rc",
|
||||||
|
"enable_push": true,
|
||||||
|
"enable_push_whitelist": true,
|
||||||
|
"push_whitelist_usernames": ["jmiller"],
|
||||||
|
"enable_force_push": false,
|
||||||
|
"enable_force_push_allowlist": false,
|
||||||
|
"force_push_allowlist_usernames": [],
|
||||||
|
"enable_merge_whitelist": false,
|
||||||
|
"required_approvals": 0,
|
||||||
|
"block_on_rejected_reviews": false,
|
||||||
|
"priority": 3
|
||||||
|
}'
|
||||||
|
|
||||||
|
RULE_BETA='{
|
||||||
|
"rule_name": "beta",
|
||||||
|
"enable_push": true,
|
||||||
|
"enable_push_whitelist": true,
|
||||||
|
"push_whitelist_usernames": ["jmiller"],
|
||||||
|
"enable_force_push": false,
|
||||||
|
"enable_force_push_allowlist": false,
|
||||||
|
"force_push_allowlist_usernames": [],
|
||||||
|
"enable_merge_whitelist": false,
|
||||||
|
"required_approvals": 0,
|
||||||
|
"block_on_rejected_reviews": false,
|
||||||
|
"priority": 4
|
||||||
|
}'
|
||||||
|
|
||||||
|
RULE_ALPHA='{
|
||||||
|
"rule_name": "alpha",
|
||||||
|
"enable_push": true,
|
||||||
|
"enable_push_whitelist": true,
|
||||||
|
"push_whitelist_usernames": ["jmiller"],
|
||||||
|
"enable_force_push": false,
|
||||||
|
"enable_force_push_allowlist": false,
|
||||||
|
"force_push_allowlist_usernames": [],
|
||||||
|
"enable_merge_whitelist": false,
|
||||||
|
"required_approvals": 0,
|
||||||
|
"block_on_rejected_reviews": false,
|
||||||
|
"priority": 5
|
||||||
|
}'
|
||||||
|
|
||||||
|
RULES=("$RULE_MAIN" "$RULE_DEV" "$RULE_RC" "$RULE_BETA" "$RULE_ALPHA")
|
||||||
|
RULE_NAMES=("main" "dev" "rc" "beta" "alpha")
|
||||||
|
|
||||||
|
# ── Apply rules to each repo ──────────────────────────────
|
||||||
|
for REPO in $REPOS; do
|
||||||
|
echo ""
|
||||||
|
echo "═══ ${REPO} ═══"
|
||||||
|
|
||||||
|
for i in "${!RULES[@]}"; do
|
||||||
|
RULE="${RULES[$i]}"
|
||||||
|
NAME="${RULE_NAMES[$i]}"
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" = "true" ]; then
|
||||||
|
echo " [DRY RUN] Would apply rule: ${NAME}"
|
||||||
|
SKIPPED=$((SKIPPED + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete existing rule if present (idempotent recreate)
|
||||||
|
ENCODED_NAME=$(echo "$NAME" | sed 's|/|%2F|g')
|
||||||
|
curl -sS -o /dev/null -w "" \
|
||||||
|
-X DELETE \
|
||||||
|
-H "Authorization: token ${GA_TOKEN}" \
|
||||||
|
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections/${ENCODED_NAME}" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Create rule
|
||||||
|
RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$RULE" \
|
||||||
|
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections")
|
||||||
|
|
||||||
|
HTTP=$(echo "$RESPONSE" | tail -1)
|
||||||
|
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||||
|
|
||||||
|
if [ "$HTTP" = "201" ]; then
|
||||||
|
echo " ✅ ${NAME}"
|
||||||
|
SUCCESS=$((SUCCESS + 1))
|
||||||
|
else
|
||||||
|
echo " ❌ ${NAME} (HTTP ${HTTP}): $(echo "$BODY" | jq -r '.message // .' 2>/dev/null | head -1)"
|
||||||
|
FAILED=$((FAILED + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# ── Summary ───────────────────────────────────────────────
|
||||||
|
echo ""
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
|
echo " ✅ Success: ${SUCCESS}"
|
||||||
|
echo " ❌ Failed: ${FAILED}"
|
||||||
|
echo " ⏭️ Skipped: ${SKIPPED}"
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
|
|
||||||
|
if [ "$FAILED" -gt 0 ]; then
|
||||||
|
echo "::warning::${FAILED} rule(s) failed to apply"
|
||||||
|
fi
|
||||||
@@ -2,10 +2,9 @@
|
|||||||
<moko-platform xmlns="https://standards.mokoconsulting.tech/moko-platform/1.0" schema-version="1.0">
|
<moko-platform xmlns="https://standards.mokoconsulting.tech/moko-platform/1.0" schema-version="1.0">
|
||||||
<identity>
|
<identity>
|
||||||
<name>MokoJoomCross</name>
|
<name>MokoJoomCross</name>
|
||||||
<display-name>Package - MokoJoomCross</display-name>
|
|
||||||
<org>MokoConsulting</org>
|
<org>MokoConsulting</org>
|
||||||
<description>Cross-posting Joomla content to social media, email marketing, and chat platforms</description>
|
<description>Cross-posting Joomla content to social media, email marketing, and chat platforms</description>
|
||||||
<version>01.00.26</version>
|
<version>01.00.00-dev</version>
|
||||||
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
|
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
|
||||||
</identity>
|
</identity>
|
||||||
<governance>
|
<governance>
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow
|
||||||
|
# INGROUP: moko-platform.Release
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
|
# PATH: /.mokogitea/workflows/auto-bump.yml
|
||||||
|
# VERSION: 09.02.00
|
||||||
|
# BRIEF: Auto patch-bump version on every push to dev (skips merge commits)
|
||||||
|
|
||||||
|
name: "Universal: Auto Version Bump"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
- rc
|
||||||
|
- 'feature/**'
|
||||||
|
- 'patch/**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump:
|
||||||
|
name: Version Bump
|
||||||
|
runs-on: release
|
||||||
|
if: >-
|
||||||
|
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip bump]') &&
|
||||||
|
!startsWith(github.event.head_commit.message, 'Merge pull request')
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Setup moko-platform tools
|
||||||
|
run: |
|
||||||
|
if ! command -v composer &> /dev/null; then
|
||||||
|
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
if [ -d "/opt/moko-platform/cli" ]; then
|
||||||
|
echo "MOKO_CLI=/opt/moko-platform/cli" >> "$GITHUB_ENV"
|
||||||
|
else
|
||||||
|
git clone --depth 1 --branch main --quiet \
|
||||||
|
"https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/MokoConsulting/moko-platform.git" \
|
||||||
|
/tmp/moko-platform-api
|
||||||
|
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet
|
||||||
|
echo "MOKO_CLI=/tmp/moko-platform-api/cli" >> "$GITHUB_ENV"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Bump version
|
||||||
|
run: |
|
||||||
|
php ${MOKO_CLI}/version_auto_bump.php \
|
||||||
|
--path . --branch "${GITHUB_REF_NAME}" \
|
||||||
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||||
|
--repo-url "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow
|
||||||
|
# INGROUP: MokoStandards.Universal
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
|
# PATH: /.mokogitea/workflows/branch-cleanup.yml
|
||||||
|
# VERSION: 01.00.00
|
||||||
|
# BRIEF: Delete feature branches after PR merge
|
||||||
|
|
||||||
|
name: "Branch Cleanup"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cleanup:
|
||||||
|
name: Delete merged branch
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: >-
|
||||||
|
github.event.pull_request.merged == true &&
|
||||||
|
github.event.pull_request.head.ref != 'dev' &&
|
||||||
|
github.event.pull_request.head.ref != 'main'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Delete source branch
|
||||||
|
run: |
|
||||||
|
BRANCH="${{ github.event.pull_request.head.ref }}"
|
||||||
|
API="${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}/api/v1/repos/${{ github.repository }}/branches"
|
||||||
|
ENCODED=$(php -r "echo rawurlencode('${BRANCH}');")
|
||||||
|
|
||||||
|
STATUS=$(curl -sf -o /dev/null -w "%{http_code}" -X DELETE \
|
||||||
|
-H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||||
|
"${API}/${ENCODED}" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ "$STATUS" = "204" ]; then
|
||||||
|
echo "Deleted branch: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
elif [ "$STATUS" = "404" ]; then
|
||||||
|
echo "Branch already deleted: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "::warning::Failed to delete branch ${BRANCH} (HTTP ${STATUS})"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# DISABLED — auto-release Step 11 recreates dev from main after every release.
|
||||||
|
# Cascade-dev is redundant and causes version conflicts when both main and dev
|
||||||
|
# have different version numbers in templateDetails.xml / manifest.xml.
|
||||||
|
name: "Cascade Main → Dev (DISABLED)"
|
||||||
|
on: workflow_dispatch
|
||||||
|
jobs:
|
||||||
|
noop:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "Cascade disabled — auto-release handles dev recreation"
|
||||||
@@ -47,9 +47,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Clone MokoStandards
|
- name: Clone MokoStandards
|
||||||
env:
|
env:
|
||||||
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN || secrets.MOKOGITEA_TOKEN || github.token }}
|
GA_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN || secrets.MOKOGITEA_TOKEN || github.token }}
|
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||||
MOKO_CLONE_HOST: ${{ secrets.MOKOGITEA_TOKEN && 'git.mokoconsulting.tech/MokoConsulting' || 'github.com/mokoconsulting-tech' }}
|
MOKO_CLONE_HOST: ${{ secrets.GA_TOKEN && 'git.mokoconsulting.tech/MokoConsulting' || 'github.com/mokoconsulting-tech' }}
|
||||||
run: |
|
run: |
|
||||||
git clone --depth 1 --branch main --quiet \
|
git clone --depth 1 --branch main --quiet \
|
||||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoStandards-API.git" \
|
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoStandards-API.git" \
|
||||||
@@ -57,7 +57,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
env:
|
env:
|
||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.MOKOGITEA_TOKEN || github.token }}"}}'
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
||||||
run: |
|
run: |
|
||||||
if [ -f "composer.json" ]; then
|
if [ -f "composer.json" ]; then
|
||||||
composer install \
|
composer install \
|
||||||
@@ -354,7 +354,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
env:
|
env:
|
||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.MOKOGITEA_TOKEN || github.token }}"}}'
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
||||||
run: |
|
run: |
|
||||||
if [ -f "composer.json" ]; then
|
if [ -f "composer.json" ]; then
|
||||||
composer install \
|
composer install \
|
||||||
@@ -404,7 +404,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
env:
|
env:
|
||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.MOKOGITEA_TOKEN || github.token }}"}}'
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
||||||
run: |
|
run: |
|
||||||
if [ -f "composer.json" ]; then
|
if [ -f "composer.json" ]; then
|
||||||
composer install --no-interaction --prefer-dist --optimize-autoloader
|
composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: moko-platform.Automation
|
# INGROUP: moko-platform.Automation
|
||||||
# VERSION: 01.00.26
|
# VERSION: 01.00.00
|
||||||
# BRIEF: Auto-create feature branch when an issue is opened
|
# BRIEF: Auto-create feature branch when an issue is opened
|
||||||
|
|
||||||
name: "Universal: Issue Branch"
|
name: "Universal: Issue Branch"
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Create branch and comment
|
- name: Create branch and comment
|
||||||
run: |
|
run: |
|
||||||
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
TOKEN="${{ secrets.GA_TOKEN }}"
|
||||||
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
||||||
ISSUE_NUM="${{ github.event.issue.number }}"
|
ISSUE_NUM="${{ github.event.issue.number }}"
|
||||||
ISSUE_TITLE="${{ github.event.issue.title }}"
|
ISSUE_TITLE="${{ github.event.issue.title }}"
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ on:
|
|||||||
types: [closed]
|
types: [closed]
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
pull_request_target:
|
|
||||||
types: [synchronize, opened, reopened]
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
stability:
|
stability:
|
||||||
@@ -47,8 +43,7 @@ jobs:
|
|||||||
runs-on: release
|
runs-on: release
|
||||||
if: >-
|
if: >-
|
||||||
github.event_name == 'workflow_dispatch' ||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev') ||
|
(github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev')
|
||||||
(github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main')
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -56,7 +51,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}
|
|
||||||
|
|
||||||
- name: Setup moko-platform tools
|
- name: Setup moko-platform tools
|
||||||
env:
|
env:
|
||||||
@@ -66,6 +60,7 @@ jobs:
|
|||||||
if ! command -v composer &> /dev/null; then
|
if ! command -v composer &> /dev/null; then
|
||||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
# Always fetch latest CLI tools — never use stale cache from previous runs
|
||||||
rm -rf /tmp/moko-platform-api
|
rm -rf /tmp/moko-platform-api
|
||||||
git clone --depth 1 --branch main --quiet \
|
git clone --depth 1 --branch main --quiet \
|
||||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||||
@@ -81,12 +76,7 @@ jobs:
|
|||||||
- name: Resolve metadata and bump version
|
- name: Resolve metadata and bump version
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
# Auto-detect stability: RC for PRs targeting main, else use input or default to development
|
STABILITY="${{ inputs.stability || 'development' }}"
|
||||||
if [ "${{ github.event_name }}" = "pull_request_target" ] && [ "${{ github.event.pull_request.base.ref }}" = "main" ]; then
|
|
||||||
STABILITY="release-candidate"
|
|
||||||
else
|
|
||||||
STABILITY="${{ inputs.stability || 'development' }}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$STABILITY" in
|
case "$STABILITY" in
|
||||||
development) SUFFIX="-dev"; TAG="development" ;;
|
development) SUFFIX="-dev"; TAG="development" ;;
|
||||||
@@ -95,23 +85,20 @@ jobs:
|
|||||||
release-candidate) SUFFIX="-rc"; TAG="release-candidate" ;;
|
release-candidate) SUFFIX="-rc"; TAG="release-candidate" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Bump version via CLI: patch for dev/alpha/beta, minor for RC
|
# Read current version (bump already handled by push workflow)
|
||||||
case "$STABILITY" in
|
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null)
|
||||||
release-candidate) BUMP="minor" ;;
|
[ -z "$VERSION" ] && VERSION="00.00.01"
|
||||||
*) BUMP="patch" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
php ${MOKO_CLI}/version_bump.php --path . $([ "$BUMP" = "minor" ] && echo "--minor") 2>/dev/null || true
|
# Strip any existing suffix from version before applying stability
|
||||||
|
|
||||||
# Set stability suffix and verify consistency
|
|
||||||
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "00.00.01")
|
|
||||||
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
||||||
|
|
||||||
php ${MOKO_CLI}/version_set_platform.php \
|
php ${MOKO_CLI}/version_set_platform.php \
|
||||||
--path . --version "$VERSION" --branch "${{ github.ref_name }}" --stability "$STABILITY" 2>/dev/null || true
|
--path . --version "$VERSION" --branch "${{ github.ref_name }}" --stability "$STABILITY" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Verify version consistency across all files
|
||||||
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||||
|
|
||||||
# Append suffix for output
|
# Update VERSION variable with suffix
|
||||||
if [ -n "$SUFFIX" ]; then
|
if [ -n "$SUFFIX" ]; then
|
||||||
VERSION="${VERSION}${SUFFIX}"
|
VERSION="${VERSION}${SUFFIX}"
|
||||||
fi
|
fi
|
||||||
@@ -157,41 +144,6 @@ jobs:
|
|||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
--repo "${GITEA_REPO}" --branch dev --prerelease
|
--repo "${GITEA_REPO}" --branch dev --prerelease
|
||||||
|
|
||||||
- name: Update release notes from CHANGELOG.md
|
|
||||||
run: |
|
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
|
|
||||||
# Extract [Unreleased] section from changelog (everything between [Unreleased] and next ## heading)
|
|
||||||
if [ -f "CHANGELOG.md" ]; then
|
|
||||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
|
||||||
[ -z "$NOTES" ] && NOTES="Release ${VERSION}"
|
|
||||||
else
|
|
||||||
NOTES="Release ${VERSION}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update release body via API
|
|
||||||
RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
|
||||||
"${API_BASE}/releases/tags/${TAG}" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ -n "$RELEASE_ID" ]; then
|
|
||||||
python3 -c "
|
|
||||||
import json, urllib.request
|
|
||||||
body = open('/dev/stdin').read()
|
|
||||||
payload = json.dumps({'body': body}).encode()
|
|
||||||
req = urllib.request.Request(
|
|
||||||
'${API_BASE}/releases/${RELEASE_ID}',
|
|
||||||
data=payload, method='PATCH',
|
|
||||||
headers={
|
|
||||||
'Authorization': 'token ${{ secrets.MOKOGITEA_TOKEN }}',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
})
|
|
||||||
urllib.request.urlopen(req)
|
|
||||||
" <<< "$NOTES"
|
|
||||||
echo "Release notes updated from CHANGELOG.md"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build package and upload
|
- name: Build package and upload
|
||||||
id: package
|
id: package
|
||||||
run: |
|
run: |
|
||||||
@@ -203,8 +155,55 @@ jobs:
|
|||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
--repo "${GITEA_REPO}" --output /tmp || true
|
--repo "${GITEA_REPO}" --output /tmp || true
|
||||||
|
|
||||||
# updates.xml is generated dynamically by MokoGitea license server
|
- name: Update updates.xml
|
||||||
# No need to build, commit, or sync updates.xml from workflows
|
if: steps.platform.outputs.platform == 'joomla'
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||||
|
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||||
|
|
||||||
|
if [ ! -f "updates.xml" ]; then
|
||||||
|
echo "No updates.xml -- skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
SHA_FLAG=""
|
||||||
|
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
||||||
|
|
||||||
|
php ${MOKO_CLI}/updates_xml_build.php \
|
||||||
|
--path . --version "${VERSION}" --stability "${STABILITY}" \
|
||||||
|
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
||||||
|
${SHA_FLAG}
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
git add updates.xml
|
||||||
|
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
||||||
|
git push origin HEAD 2>&1 || echo "WARNING: push failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "Sync updates.xml to all branches"
|
||||||
|
if: steps.platform.outputs.platform == 'joomla'
|
||||||
|
run: |
|
||||||
|
CURRENT_BRANCH="${{ github.ref_name }}"
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
|
||||||
|
for BRANCH in main dev; do
|
||||||
|
[ "$BRANCH" = "$CURRENT_BRANCH" ] && continue
|
||||||
|
echo "Syncing updates.xml -> ${BRANCH}"
|
||||||
|
git fetch origin "${BRANCH}" 2>/dev/null || continue
|
||||||
|
git checkout "origin/${BRANCH}" -- updates.xml 2>/dev/null || continue
|
||||||
|
git checkout "${CURRENT_BRANCH}" -- updates.xml
|
||||||
|
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||||
|
git add updates.xml
|
||||||
|
git commit -m "chore: sync updates.xml from ${CURRENT_BRANCH} [skip ci]"
|
||||||
|
git push origin HEAD:refs/heads/${BRANCH} 2>&1 || echo "WARNING: push to ${BRANCH} failed"
|
||||||
|
fi
|
||||||
|
git checkout "${CURRENT_BRANCH}" 2>/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
- name: "Delete lesser pre-release channels (cascade)"
|
- name: "Delete lesser pre-release channels (cascade)"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|||||||
@@ -0,0 +1,312 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow
|
||||||
|
# INGROUP: moko-platform.Universal
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
|
# PATH: /templates/workflows/update-server.yml
|
||||||
|
# VERSION: 05.00.00
|
||||||
|
# BRIEF: Pre-release build + update server XML for dev/alpha/beta/rc branches
|
||||||
|
#
|
||||||
|
# Thin wrapper around moko-platform CLI tools.
|
||||||
|
# Builds packages, updates updates.xml, and optionally deploys via SFTP.
|
||||||
|
#
|
||||||
|
# Joomla filters update entries by the user's "Minimum Stability" setting.
|
||||||
|
|
||||||
|
name: "Update Server"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
- 'dev/**'
|
||||||
|
- 'alpha/**'
|
||||||
|
- 'beta/**'
|
||||||
|
- 'rc/**'
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'htdocs/**'
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
- 'dev/**'
|
||||||
|
- 'alpha/**'
|
||||||
|
- 'beta/**'
|
||||||
|
- 'rc/**'
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'htdocs/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
stability:
|
||||||
|
description: 'Stability tag'
|
||||||
|
required: true
|
||||||
|
default: 'development'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- development
|
||||||
|
- alpha
|
||||||
|
- beta
|
||||||
|
- rc
|
||||||
|
- stable
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||||
|
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
||||||
|
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-xml:
|
||||||
|
name: Update Server
|
||||||
|
runs-on: release
|
||||||
|
if: >-
|
||||||
|
github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' || github.event_name == 'push'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup moko-platform tools
|
||||||
|
env:
|
||||||
|
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
|
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||||
|
COMPOSER_AUTH: '{"http-basic":{"git.mokoconsulting.tech":{"username":"token","password":"${{ secrets.MOKOGITEA_TOKEN }}"}}}'
|
||||||
|
run: |
|
||||||
|
if ! command -v composer &> /dev/null; then
|
||||||
|
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
# Always fetch latest CLI tools — never use stale cache from previous runs
|
||||||
|
rm -rf /tmp/moko-platform
|
||||||
|
git clone --depth 1 --branch main --quiet \
|
||||||
|
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||||
|
/tmp/moko-platform 2>/dev/null || true
|
||||||
|
if [ -d "/tmp/moko-platform" ] && [ -f "/tmp/moko-platform/composer.json" ]; then
|
||||||
|
cd /tmp/moko-platform && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
echo "MOKO_CLI=/tmp/moko-platform/cli" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Detect platform
|
||||||
|
id: platform
|
||||||
|
run: php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
||||||
|
|
||||||
|
- name: Resolve stability and bump version
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
BRANCH="${{ github.ref_name }}"
|
||||||
|
|
||||||
|
# Configure git for bot pushes
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
|
|
||||||
|
# Auto-bump patch version
|
||||||
|
php ${MOKO_CLI}/version_bump.php --path . 2>/dev/null || true
|
||||||
|
|
||||||
|
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "0.0.0")
|
||||||
|
|
||||||
|
# Strip any existing suffix before applying stability
|
||||||
|
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
||||||
|
|
||||||
|
# Determine stability from branch or manual input
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
STABILITY="${{ inputs.stability }}"
|
||||||
|
elif [[ "$BRANCH" == rc/* ]]; then
|
||||||
|
STABILITY="rc"
|
||||||
|
elif [[ "$BRANCH" == beta/* ]]; then
|
||||||
|
STABILITY="beta"
|
||||||
|
elif [[ "$BRANCH" == alpha/* ]]; then
|
||||||
|
STABILITY="alpha"
|
||||||
|
else
|
||||||
|
STABILITY="development"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Version suffix per stability stream
|
||||||
|
case "$STABILITY" in
|
||||||
|
development) SUFFIX="-dev"; TAG="development" ;;
|
||||||
|
alpha) SUFFIX="-alpha"; TAG="alpha" ;;
|
||||||
|
beta) SUFFIX="-beta"; TAG="beta" ;;
|
||||||
|
rc) SUFFIX="-rc"; TAG="release-candidate" ;;
|
||||||
|
*) SUFFIX=""; TAG="stable" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Propagate version with stability suffix to all manifest files
|
||||||
|
php ${MOKO_CLI}/version_set_platform.php \
|
||||||
|
--path . --version "$VERSION" --branch "$BRANCH" --stability "$STABILITY" 2>/dev/null || true
|
||||||
|
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||||
|
|
||||||
|
# Re-read version (now includes suffix from version_set_platform)
|
||||||
|
if [ -n "$SUFFIX" ]; then
|
||||||
|
VERSION="${VERSION}${SUFFIX}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "display_version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# Commit version bump if changed
|
||||||
|
git add -A
|
||||||
|
git diff --cached --quiet || {
|
||||||
|
git commit -m "chore(version): auto-bump ${VERSION} [skip ci]" \
|
||||||
|
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
||||||
|
git push
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Create release and upload package
|
||||||
|
id: package
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
|
||||||
|
# Create or update Gitea release
|
||||||
|
php ${MOKO_CLI}/release_create.php \
|
||||||
|
--path . --version "$VERSION" --tag "$TAG" \
|
||||||
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
|
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
|
||||||
|
|
||||||
|
# Build package and upload
|
||||||
|
php ${MOKO_CLI}/release_package.php \
|
||||||
|
--path . --version "$VERSION" --tag "$TAG" \
|
||||||
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
|
--repo "${GITEA_REPO}" --output /tmp || true
|
||||||
|
|
||||||
|
- name: Update updates.xml
|
||||||
|
if: steps.platform.outputs.platform == 'joomla'
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||||
|
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||||
|
|
||||||
|
if [ ! -f "updates.xml" ]; then
|
||||||
|
echo "No updates.xml — skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
SHA_FLAG=""
|
||||||
|
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
||||||
|
|
||||||
|
php ${MOKO_CLI}/updates_xml_build.php \
|
||||||
|
--path . --version "${VERSION}" --stability "${STABILITY}" \
|
||||||
|
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
||||||
|
${SHA_FLAG}
|
||||||
|
|
||||||
|
# Commit and push updates.xml
|
||||||
|
git add updates.xml
|
||||||
|
git diff --cached --quiet || {
|
||||||
|
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
||||||
|
git push
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Sync updates.xml to main
|
||||||
|
if: github.ref_name != 'main' && steps.platform.outputs.platform == 'joomla'
|
||||||
|
run: |
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
GITEA_TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||||
|
|
||||||
|
FILE_SHA=$(curl -sf -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/contents/updates.xml?ref=main" | python3 -c "import sys,json; print(json.load(sys.stdin).get('sha',''))" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ -n "$FILE_SHA" ] && [ -f "updates.xml" ]; then
|
||||||
|
python3 -c "
|
||||||
|
import base64, json, urllib.request, sys
|
||||||
|
with open('updates.xml', 'rb') as f:
|
||||||
|
content = base64.b64encode(f.read()).decode()
|
||||||
|
payload = json.dumps({
|
||||||
|
'content': content,
|
||||||
|
'sha': '${FILE_SHA}',
|
||||||
|
'message': 'chore: sync updates.xml from ${{ steps.meta.outputs.stability }} [skip ci]',
|
||||||
|
'branch': 'main'
|
||||||
|
}).encode()
|
||||||
|
req = urllib.request.Request(
|
||||||
|
'${API_BASE}/contents/updates.xml',
|
||||||
|
data=payload, method='PUT',
|
||||||
|
headers={
|
||||||
|
'Authorization': 'token ${GITEA_TOKEN}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
})
|
||||||
|
try:
|
||||||
|
urllib.request.urlopen(req)
|
||||||
|
print('updates.xml synced to main')
|
||||||
|
except Exception as e:
|
||||||
|
print(f'WARNING: sync to main failed: {e}', file=sys.stderr)
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: SFTP deploy to dev server
|
||||||
|
if: contains(github.ref, 'dev/') || github.ref == 'refs/heads/dev'
|
||||||
|
env:
|
||||||
|
DEV_HOST: ${{ vars.DEV_FTP_HOST }}
|
||||||
|
DEV_PATH: ${{ vars.DEV_FTP_PATH }}
|
||||||
|
DEV_SUFFIX: ${{ vars.DEV_FTP_SUFFIX }}
|
||||||
|
DEV_USER: ${{ vars.DEV_FTP_USERNAME }}
|
||||||
|
DEV_PORT: ${{ vars.DEV_FTP_PORT }}
|
||||||
|
DEV_KEY: ${{ secrets.DEV_FTP_KEY }}
|
||||||
|
DEV_PASS: ${{ secrets.DEV_FTP_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
# Permission check: admin or maintain role required
|
||||||
|
ACTOR="${{ github.actor }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
|
||||||
|
PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||||
|
"${API_BASE}/collaborators/${ACTOR}/permission" 2>/dev/null | \
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin).get('permission','read'))" 2>/dev/null || echo "read")
|
||||||
|
case "$PERMISSION" in
|
||||||
|
admin|maintain|write) ;;
|
||||||
|
*)
|
||||||
|
echo "Deploy denied: ${ACTOR} has '${PERMISSION}' — requires admin, maintain, or write"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -z "$DEV_HOST" ] || [ -z "$DEV_PATH" ] && { echo "DEV FTP not configured — skipping SFTP"; exit 0; }
|
||||||
|
|
||||||
|
SOURCE_DIR="src"
|
||||||
|
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="htdocs"
|
||||||
|
[ ! -d "$SOURCE_DIR" ] && exit 0
|
||||||
|
|
||||||
|
PORT="${DEV_PORT:-22}"
|
||||||
|
REMOTE="${DEV_PATH%/}"
|
||||||
|
[ -n "$DEV_SUFFIX" ] && REMOTE="${REMOTE}/${DEV_SUFFIX#/}"
|
||||||
|
|
||||||
|
printf '{"host":"%s","port":%s,"username":"%s","remotePath":"%s"' \
|
||||||
|
"$DEV_HOST" "$PORT" "$DEV_USER" "$REMOTE" > /tmp/sftp-config.json
|
||||||
|
if [ -n "$DEV_KEY" ]; then
|
||||||
|
echo "$DEV_KEY" > /tmp/deploy_key && chmod 600 /tmp/deploy_key
|
||||||
|
printf ',"privateKeyPath":"/tmp/deploy_key"}' >> /tmp/sftp-config.json
|
||||||
|
else
|
||||||
|
printf ',"password":"%s"}' "$DEV_PASS" >> /tmp/sftp-config.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLATFORM=$(php ${MOKO_CLI}/platform_detect.php --path . 2>/dev/null || true)
|
||||||
|
if [ "$PLATFORM" = "waas-component" ] && [ -f "${MOKO_CLI}/../deploy/deploy-joomla.php" ]; then
|
||||||
|
php ${MOKO_CLI}/../deploy/deploy-joomla.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
||||||
|
elif [ -f "${MOKO_CLI}/../deploy/deploy-sftp.php" ]; then
|
||||||
|
php ${MOKO_CLI}/../deploy/deploy-sftp.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
||||||
|
fi
|
||||||
|
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
||||||
|
echo "SFTP deploy to dev complete" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||||
|
DISPLAY="${{ steps.meta.outputs.display_version }}"
|
||||||
|
echo "## Update Server" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Stability | \`${STABILITY}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Version | \`${DISPLAY}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
+11
-191
@@ -1,6 +1,6 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
<!-- VERSION: 01.00.26 -->
|
<!-- VERSION: 01.00.00 -->
|
||||||
|
|
||||||
All notable changes to MokoJoomCross will be documented in this file.
|
All notable changes to MokoJoomCross will be documented in this file.
|
||||||
|
|
||||||
@@ -8,195 +8,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- **C-1 OauthController**: Added CSRF nonce validation to OAuth callback — session-based nonce is generated during `authorize()`, embedded in the state parameter, and verified in `callback()` to prevent CSRF attacks
|
|
||||||
- **C-2 DispatchController**: Added POST method enforcement — rejects non-POST requests with 405 status
|
|
||||||
- **C-5 ServiceModel**: Credential form fields (`cred_*`) are now collected into the `credentials` JSON column on save, and expanded back into individual fields on load — previously these fields were silently discarded
|
|
||||||
- **H-1 Event pattern**: Fixed Joomla 5 SubscriberInterface incompatibility where `onMokoJoomCrossGetServices` by-reference pattern silently lost all service plugins — dispatchers now read plugin instances from Event ArrayAccess indices after dispatch
|
|
||||||
- **H-4 ServiceTable**: Added `check()` method with alias generation, required field validation (title, service_type), timestamp management, and JSON defaults for credentials/params
|
|
||||||
- **H-9 WebhookService**: Fixed credential key mismatch — `publish()` and `validateCredentials()` now use keys matching the service.xml form fields (`url`, `method`, `auth_type`, `bearer_token`, `basic_username`, `basic_password`, `content_type`) and properly apply Bearer/Basic auth headers
|
|
||||||
- **M-4 ServiceIconHelper**: Escaped `$extraClass` parameter in `renderIcon()` with `htmlspecialchars()` to prevent XSS
|
|
||||||
- **M-5 Content plugin**: Fixed double-escaped HTML in cross-post history panel — uses `setFieldAttribute()` to inject history HTML into the note field description after XML load, avoiding XML attribute encoding
|
|
||||||
|
|
||||||
- **Content plugin**: Fixed `onContentBeforeDisplay` signature for Joomla 5/6 — now accepts `BeforeDisplayEvent` object instead of individual parameters
|
|
||||||
|
|
||||||
- **QueueProcessor**: Replaced read-then-write DB lock with MySQL advisory locks (`GET_LOCK`/`RELEASE_LOCK`) to eliminate race condition
|
|
||||||
- **Twitter/X**: Replaced Bearer token auth with OAuth 1.0a (HMAC-SHA1) — Bearer tokens are app-only and cannot create tweets
|
|
||||||
- **service.xml**: Fixed missing closing `</field>` tag on webhook method field
|
|
||||||
- **Views**: Added missing `Toolbar` and `Route` imports in Logs, Posts, Services, Template, Templates HtmlView files
|
|
||||||
- **13 service plugins**: Fixed broken `publish()` methods that had literal placeholder URLs instead of using credential values — ActivityPub, Blogger, Ghost, Google Business, Hashnode, Matrix, Medium, Nostr, RSS Feed, Threads, Tumblr, WhatsApp, WordPress
|
|
||||||
- **Ghost**: Proper JWT auth from `{id}:{secret}` admin API key format
|
|
||||||
- **WordPress**: Correct Basic Auth (not Bearer) with Application Passwords
|
|
||||||
- **Medium**: 2-step flow — fetch user ID via /v1/me, then post
|
|
||||||
- **Matrix**: PUT with transaction ID for idempotent message sending
|
|
||||||
- **Hashnode**: GraphQL mutation with proper query structure
|
|
||||||
- **Threads**: 2-step container creation + publish flow
|
|
||||||
- **WhatsApp**: Meta Cloud API with messaging_product payload
|
|
||||||
- **Nostr**: Stub with clear "not yet implemented" message (requires WebSocket)
|
|
||||||
- **RSS Feed**: Local service — no external API, always succeeds
|
|
||||||
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- **ServiceIconHelper**: Centralised icon mapping for all 34 service types — replaces per-template icon arrays with `ServiceIconHelper::getIcon()` / `::renderIcon()`
|
- Initial package structure with component, system plugin, content plugin, and webservices plugin
|
||||||
- **Service Stats drill-down**: New `servicestats` view with per-service analytics — post counts, success rate, daily trend chart, recent posts table, and top articles list
|
- Admin component with dashboard, post queue, services management, and activity logs
|
||||||
- **Dashboard service links**: Service breakdown table rows now link to the per-service stats view with service type icons
|
- System plugin triggering cross-post on article publish via `onContentAfterSave`
|
||||||
- **Posts list icons**: Service type column in the posts list now shows the service icon
|
- Content plugin adding cross-post controls to article editor
|
||||||
- **Category routing rules**: New `#__mokojoomcross_category_rules` table to whitelist services per Joomla category — if rules exist for a category, only those services receive posts; no rules = all services (backward compatible)
|
- WebServices API plugin with REST endpoints for posts and services
|
||||||
- **CrossPostDispatcher**: Category rule filtering integrated before per-article service filter in the dispatch loop
|
|
||||||
- **Template editor**: Live character counter below template body textarea with platform-aware limits (green/yellow/red badges)
|
|
||||||
- **Template editor**: Added `{tags}`, `{hashtags}`, and `{field:xxx}` rows to the placeholder reference table
|
|
||||||
- **Content plugin**: Cross-post history panel in article editor showing last 10 posts with status badges, service names, timestamps, and error messages
|
|
||||||
- **Config**: New "Category Rules" fieldset with explanatory note about the feature
|
|
||||||
|
|
||||||
- **CrossPostDispatcher**: New static helper (`com_mokojoomcross/Helper/CrossPostDispatcher`) centralising dispatch logic for reuse by all source plugins
|
|
||||||
- **Content plugin**: Added `onContentAfterSave` and `onContentChangeState` handlers with Joomla 5/6 event compatibility, dispatching via `CrossPostDispatcher`
|
|
||||||
- **plg_system_mokojoomcross_events**: New source plugin for MokoJoomCalendar — cross-posts calendar events when published
|
|
||||||
- **plg_system_mokojoomcross_gallery**: New source plugin for MokoJoomGallery — cross-posts galleries and images when published
|
|
||||||
|
|
||||||
- **Credential fields**: Added fields for 19 previously missing services (Pinterest, Tumblr, TikTok, Nostr, ActivityPub, Brevo, ConvertKit, Constant Contact, Hashnode, Blogger, Google Business, RSS Feed config)
|
|
||||||
- **Twitter**: Access Token and Access Token Secret fields for OAuth 1.0a
|
|
||||||
- **LinkedIn**: Refresh token field for automatic token renewal
|
|
||||||
- **Bluesky**: PDS URL field for self-hosted instances
|
|
||||||
- **Discord**: Username and avatar URL override fields
|
|
||||||
- **Mailchimp**: From name and from email fields
|
|
||||||
- **SendGrid**: From email and from name fields
|
|
||||||
- **Reddit**: Account password field for script-type OAuth
|
|
||||||
- **WordPress**: Default post status selector (draft/publish)
|
|
||||||
- **Dev.to**: Organization ID field
|
|
||||||
- **Ghost**: Default post status selector (draft/published)
|
|
||||||
- **Webhook**: Auth type selector (none/bearer/basic), auth token field, content type selector (JSON/form)
|
|
||||||
- **RSS Feed**: Feed title and max items config fields
|
|
||||||
- **OAuth services**: Added Pinterest, Tumblr, TikTok, Constant Contact, Blogger, Google Business to OAuth authorize flow
|
|
||||||
- **Developer Guide**: Comprehensive wiki page for building new service plugins
|
|
||||||
- **Help articles**: 42 KB articles on mokoconsulting.tech (overview, installation, 34 per-service guides, templates, queue, troubleshooting)
|
|
||||||
- **Service help link**: Per-service "Setup Guide" button in service edit sidebar links to the matching KB article
|
|
||||||
- **Evergreen re-sharing**: Articles can be marked as evergreen for automatic recurring cross-posts on a configurable interval (default 30 days)
|
|
||||||
- **Post edit form**: Full CRUD for queue posts — edit message, reschedule, change status, re-queue failed posts
|
|
||||||
- **Manual post creator**: New button in Post Queue toolbar to create manual cross-posts with article/service selection, custom message, and optional scheduling
|
|
||||||
- **Scheduled posts**: Calendar picker for scheduling posts to specific date/time; scheduled_at shown in queue list
|
|
||||||
- **Dashboard trend chart**: Chart.js line chart showing daily posted vs failed counts between stat cards and service breakdown
|
|
||||||
- **Dashboard date range filter**: Period selector (7/30/90 days, all time) filters service breakdown, top articles, and trend chart
|
|
||||||
- **Hashtag placeholders**: `{tags}` (comma-separated) and `{hashtags}` (#-prefixed space-separated) template placeholders from article tags
|
|
||||||
- **Posts service filter**: SQL-driven service dropdown filter in posts list, plus search filter by article title or message content
|
|
||||||
- **CSV export**: "Export CSV" toolbar button on posts list to download filtered post data as CSV
|
|
||||||
- **WordPress canonical URL**: WordPress cross-posts now include an "Originally published at" source link appended to content with the Joomla article URL
|
|
||||||
- **REST API dispatch endpoint**: `POST /api/v1/mokojoomcross/dispatch` — trigger cross-posts for an article via API with optional service filtering, duplicate guard, and template rendering
|
|
||||||
|
|
||||||
|
|
||||||
### Added (original)
|
|
||||||
|
|
||||||
#### Core Engine
|
|
||||||
- Cross-posting engine dispatches articles to service plugins on publish
|
|
||||||
- System plugin hooks `onContentAfterSave` and `onContentChangeState`
|
|
||||||
- Duplicate guard prevents re-posting to services that already received an article
|
|
||||||
- Message template rendering with 8 placeholders: `{title}`, `{url}`, `{introtext}`, `{fulltext}`, `{image}`, `{category}`, `{author}`, `{date}`
|
|
||||||
- Custom `mokojoomcross` plugin group for extensible service architecture
|
- Custom `mokojoomcross` plugin group for extensible service architecture
|
||||||
- `MokoJoomCrossServiceInterface` contract for all service plugins
|
- Service plugins: Facebook, X/Twitter, LinkedIn, Mastodon, Bluesky, Mailchimp, Telegram, Discord, Slack
|
||||||
|
- Database tables: services, posts, templates, logs
|
||||||
#### Admin Component (5 views)
|
- Perfect Publisher Pro migration tool in installer script
|
||||||
- **Dashboard** — summary cards, posts-by-service analytics with success rates, top cross-posted articles, recent activity feed, PP Pro migration banner, page-load processing warning
|
- Message template system with per-platform placeholders
|
||||||
- **Post Queue** — list with color-coded status badges, error messages, retry counts, platform post IDs, article/service columns, date filters
|
- Post queue with scheduled posting, retry logic, and delivery tracking
|
||||||
- **Services** — CRUD with service type selector (34 platforms organized by category), default/custom mode badges, publish toggle, credential editor
|
|
||||||
- **Templates** — CRUD for message templates, per-platform assignment, placeholder reference panel, template body preview
|
|
||||||
- **Activity Logs** — list with level badges (info/warning/error), service column, context data, level and search filters
|
|
||||||
|
|
||||||
#### Queue Processing (3 methods)
|
|
||||||
- Joomla Scheduled Task plugin (`plg_task_mokojoomcross`) — preferred, processes 20 posts per run
|
|
||||||
- Page-load fallback via system plugin `onAfterRender` — configurable throttle interval, backend/frontend/both
|
|
||||||
- Shared `QueueProcessor` helper with DB lock to prevent concurrent execution
|
|
||||||
- Failed post retry with configurable max retries and exponential delay
|
|
||||||
- Scheduled post support (`scheduled_at` column)
|
|
||||||
- Automatic log cleanup based on configurable retention period
|
|
||||||
|
|
||||||
#### Per-Article Controls
|
|
||||||
- "Cross-Posting" fieldset injected into article editor via `onContentPrepareForm`
|
|
||||||
- Skip cross-posting toggle per article
|
|
||||||
- Service selection checkboxes (unchecked = post to all enabled services)
|
|
||||||
|
|
||||||
#### OAuth 2.0
|
|
||||||
- `OAuthHelper` with authorization URL generation, code-to-token exchange, token storage
|
|
||||||
- Twitter PKCE flow support
|
|
||||||
- `OauthController` with authorize and callback endpoints
|
|
||||||
- Reads client ID/secret from service plugin params
|
|
||||||
|
|
||||||
#### Perfect Publisher Pro Migration
|
|
||||||
- Reads `#__autotweet_channels` table with per-platform credential mapping
|
|
||||||
- Fallback extraction from component params when channel table missing
|
|
||||||
- Maps Facebook, Twitter, LinkedIn, Telegram, Discord, Slack, Mastodon
|
|
||||||
- Creates services in disabled state for manual verification
|
|
||||||
- One-click migration from dashboard
|
|
||||||
|
|
||||||
#### Service Plugins (34 platforms)
|
|
||||||
|
|
||||||
**Social Media (12)**
|
|
||||||
- Facebook / Meta — Graph API v19.0, default MokoWaaS app mode, page feed posting
|
|
||||||
- X / Twitter — API v2, OAuth 2.0 Bearer Token, 280 char limit
|
|
||||||
- LinkedIn — Share API v2, organization + personal profile, 3000 char limit
|
|
||||||
- Mastodon — API v1, multi-instance, hashtags, 500 char limit
|
|
||||||
- Bluesky — AT Protocol, session auth, app passwords, 300 char limit
|
|
||||||
- Threads (Meta) — Threads Publishing API, default app mode, 500 char limit
|
|
||||||
- Pinterest — Pins API v5, board selection, image-focused
|
|
||||||
- Reddit — OAuth2 link submission, subreddit selection
|
|
||||||
- Tumblr — API v2, link/text posts, OAuth 1.0a
|
|
||||||
- TikTok — Content Posting API, photo slideshows
|
|
||||||
- Nostr — NIP-01 event publishing, configurable relays
|
|
||||||
- ActivityPub — generic Fediverse (Pleroma, Akkoma, Misskey, Pixelfed)
|
|
||||||
|
|
||||||
**Chat / Messaging (8)**
|
|
||||||
- Telegram — Bot API, default @MokoWaaSBot + custom bot, HTML/Markdown, 4096 chars
|
|
||||||
- Discord — Webhooks, default MokoWaaS webhook mode, embeds, 2000 chars
|
|
||||||
- Slack — Incoming Webhooks, default MokoWaaS webhook mode, Block Kit
|
|
||||||
- Microsoft Teams — Incoming Webhooks, default mode, Adaptive Cards
|
|
||||||
- Google Chat — Webhook API, card formatting
|
|
||||||
- WhatsApp Business — Meta Cloud API, template + free-form messages
|
|
||||||
- Matrix / Element — Client-Server API, self-hosted homeserver support
|
|
||||||
- Ntfy — Push notifications, priority levels, action buttons
|
|
||||||
|
|
||||||
**Email / Newsletter (5)**
|
|
||||||
- Mailchimp — Campaigns API, audience selection, send/draft modes
|
|
||||||
- SendGrid — Marketing Campaigns API v3, Single Send creation
|
|
||||||
- Brevo (Sendinblue) — API v3, campaign creation
|
|
||||||
- ConvertKit — API v3, broadcast creation
|
|
||||||
- Constant Contact — API v3, campaign creation
|
|
||||||
|
|
||||||
**Publishing / Blogging (6)**
|
|
||||||
- Medium — Publishing API, full HTML, canonical URL, tags
|
|
||||||
- WordPress — REST API v2, Application Passwords, category mapping
|
|
||||||
- Dev.to — Forem API, markdown, series support
|
|
||||||
- Ghost — Admin API v5, JWT auth, full HTML
|
|
||||||
- Hashnode — GraphQL API, cover image, tags
|
|
||||||
- Google Blogger — Blogger API v3, labels from categories
|
|
||||||
|
|
||||||
**Business (1)**
|
|
||||||
- Google Business Profile — API v1, local posts (UPDATE/EVENT/OFFER)
|
|
||||||
|
|
||||||
**Universal (2)**
|
|
||||||
- Generic Webhook — POST/PUT to any URL, JSON/form body, custom headers (IFTTT, Zapier, n8n, Make)
|
|
||||||
- RSS Feed — dedicated cross-post feed generation
|
|
||||||
|
|
||||||
#### Plugin Configuration
|
|
||||||
- Telegram: default bot token, parse mode, link preview toggle
|
|
||||||
- Facebook: default page access token, default page ID
|
|
||||||
- Discord: default webhook URL, embed color
|
|
||||||
- Slack: default webhook URL
|
|
||||||
- LinkedIn: OAuth client ID/secret, redirect URI
|
|
||||||
- Mastodon: default instance URL, visibility, hashtags
|
|
||||||
- Bluesky: default PDS URL, auto link cards
|
|
||||||
- Mailchimp: default sender name/email, auto-send toggle
|
|
||||||
- Microsoft Teams: default webhook URL
|
|
||||||
- Threads: default webhook URL
|
|
||||||
|
|
||||||
#### Infrastructure
|
|
||||||
- 7 CI/CD workflows: CI, auto-release, pre-release, auto-bump, update-server, cascade-dev, issue-branch
|
|
||||||
- Joomla update server (`updates.xml`) with development channel
|
|
||||||
- WebServices REST API plugin with CRUD routes for posts and services
|
|
||||||
- Database: 4 tables (services, posts, templates, logs) with default templates
|
|
||||||
- Package installer with auto-enable for core + task + service plugins
|
|
||||||
- 9 wiki documentation pages
|
|
||||||
- Windows Terminal profile in Joomla dropdown
|
|
||||||
|
|
||||||
|
|
||||||
## [01.00] - 2026-05-28
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Initial release
|
|
||||||
|
|||||||
+161
-161
@@ -1,161 +1,161 @@
|
|||||||
# Contributing to Moko Consulting Projects
|
# Contributing to Moko Consulting Projects
|
||||||
|
|
||||||
Thank you for your interest in contributing. All Moko Consulting repositories follow this universal workflow and version policy.
|
Thank you for your interest in contributing. All Moko Consulting repositories follow this universal workflow and version policy.
|
||||||
|
|
||||||
## Branching Workflow
|
## Branching Workflow
|
||||||
|
|
||||||
```
|
```
|
||||||
feature/* ──PR──> dev ──draft PR──> (renamed to rc) ──merge──> main
|
feature/* ──PR──> dev ──draft PR──> (renamed to rc) ──merge──> main
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step by step
|
### Step by step
|
||||||
|
|
||||||
1. **Create a feature branch** from `dev`:
|
1. **Create a feature branch** from `dev`:
|
||||||
```bash
|
```bash
|
||||||
git checkout dev && git pull
|
git checkout dev && git pull
|
||||||
git checkout -b feature/my-change
|
git checkout -b feature/my-change
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Work and commit** on your feature branch. Push to origin.
|
2. **Work and commit** on your feature branch. Push to origin.
|
||||||
|
|
||||||
3. **Open a PR**: `feature/my-change` → `dev`. After review and checks, merge it.
|
3. **Open a PR**: `feature/my-change` → `dev`. After review and checks, merge it.
|
||||||
|
|
||||||
4. **When ready for release**, open a **draft PR**: `dev` → `main`.
|
4. **When ready for release**, open a **draft PR**: `dev` → `main`.
|
||||||
- This automatically renames the source branch to `rc` (release candidate)
|
- This automatically renames the source branch to `rc` (release candidate)
|
||||||
- An RC pre-release is built and uploaded
|
- An RC pre-release is built and uploaded
|
||||||
|
|
||||||
5. **Alpha and beta branches** are created by manually renaming the branch before the RC stage:
|
5. **Alpha and beta branches** are created by manually renaming the branch before the RC stage:
|
||||||
- Rename `dev` to `alpha` for early testing → alpha pre-release is built
|
- Rename `dev` to `alpha` for early testing → alpha pre-release is built
|
||||||
- Rename `alpha` to `beta` for feature-complete testing → beta pre-release is built
|
- Rename `alpha` to `beta` for feature-complete testing → beta pre-release is built
|
||||||
- When the draft PR is created, the branch is renamed to `rc`
|
- When the draft PR is created, the branch is renamed to `rc`
|
||||||
|
|
||||||
6. **Once PR checks pass** on the `rc` branch, mark the PR as ready and merge to `main`.
|
6. **Once PR checks pass** on the `rc` branch, mark the PR as ready and merge to `main`.
|
||||||
|
|
||||||
7. **Merging to main** triggers the stable release pipeline:
|
7. **Merging to main** triggers the stable release pipeline:
|
||||||
- Minor version bump (e.g., `02.09.xx` → `02.10.00`)
|
- Minor version bump (e.g., `02.09.xx` → `02.10.00`)
|
||||||
- Stability suffix stripped (clean version)
|
- Stability suffix stripped (clean version)
|
||||||
- Gitea release created with ZIP/tar.gz packages
|
- Gitea release created with ZIP/tar.gz packages
|
||||||
- `updates.xml` updated (Joomla extensions)
|
- `updates.xml` updated (Joomla extensions)
|
||||||
- `dev` branch recreated from `main`
|
- `dev` branch recreated from `main`
|
||||||
|
|
||||||
### Branch summary
|
### Branch summary
|
||||||
|
|
||||||
| Branch | Purpose | Created by |
|
| Branch | Purpose | Created by |
|
||||||
|--------|---------|-----------|
|
|--------|---------|-----------|
|
||||||
| `feature/*` | New features and fixes | Developer |
|
| `feature/*` | New features and fixes | Developer |
|
||||||
| `dev` | Integration branch | Auto-recreated after release |
|
| `dev` | Integration branch | Auto-recreated after release |
|
||||||
| `alpha` | Alpha pre-release testing | Manual rename from `dev` |
|
| `alpha` | Alpha pre-release testing | Manual rename from `dev` |
|
||||||
| `beta` | Beta pre-release testing | Manual rename from `alpha` |
|
| `beta` | Beta pre-release testing | Manual rename from `alpha` |
|
||||||
| `rc` | Release candidate | Auto-renamed on draft PR to main |
|
| `rc` | Release candidate | Auto-renamed on draft PR to main |
|
||||||
| `main` | Stable releases | Protected, merge only |
|
| `main` | Stable releases | Protected, merge only |
|
||||||
| `version/XX.YY.ZZ` | Archived release snapshots | Auto-created by CI |
|
| `version/XX.YY.ZZ` | Archived release snapshots | Auto-created by CI |
|
||||||
|
|
||||||
### Protected branches
|
### Protected branches
|
||||||
|
|
||||||
| Branch | Direct push | Merge via |
|
| Branch | Direct push | Merge via |
|
||||||
|--------|------------|-----------|
|
|--------|------------|-----------|
|
||||||
| `main` | Blocked (CI bot whitelisted) | PR merge only |
|
| `main` | Blocked (CI bot whitelisted) | PR merge only |
|
||||||
| `dev` | Blocked (CI bot whitelisted) | PR merge from feature/* |
|
| `dev` | Blocked (CI bot whitelisted) | PR merge from feature/* |
|
||||||
| `rc` | Blocked (CI bot whitelisted) | Auto-created on draft PR |
|
| `rc` | Blocked (CI bot whitelisted) | Auto-created on draft PR |
|
||||||
| `alpha` | Blocked (CI bot whitelisted) | Manual rename |
|
| `alpha` | Blocked (CI bot whitelisted) | Manual rename |
|
||||||
| `beta` | Blocked (CI bot whitelisted) | Manual rename |
|
| `beta` | Blocked (CI bot whitelisted) | Manual rename |
|
||||||
| `feature/*` | Open | N/A (source branch) |
|
| `feature/*` | Open | N/A (source branch) |
|
||||||
|
|
||||||
## Version Policy
|
## Version Policy
|
||||||
|
|
||||||
### Format
|
### Format
|
||||||
|
|
||||||
All versions use `XX.YY.ZZ` — three two-digit segments, zero-padded:
|
All versions use `XX.YY.ZZ` — three two-digit segments, zero-padded:
|
||||||
|
|
||||||
- **XX** — Major version (breaking changes)
|
- **XX** — Major version (breaking changes)
|
||||||
- **YY** — Minor version (new features, bumped on release to main)
|
- **YY** — Minor version (new features, bumped on release to main)
|
||||||
- **ZZ** — Patch version (auto-incremented on every push to dev/feature branches)
|
- **ZZ** — Patch version (auto-incremented on every push to dev/feature branches)
|
||||||
|
|
||||||
Rollover: patch `99` → `00` increments minor; minor `99` → `00` increments major.
|
Rollover: patch `99` → `00` increments minor; minor `99` → `00` increments major.
|
||||||
|
|
||||||
### Stability suffixes
|
### Stability suffixes
|
||||||
|
|
||||||
Each branch appends a suffix to indicate stability:
|
Each branch appends a suffix to indicate stability:
|
||||||
|
|
||||||
| Branch | Suffix | Example |
|
| Branch | Suffix | Example |
|
||||||
|--------|--------|---------|
|
|--------|--------|---------|
|
||||||
| `main` | (none) | `02.09.00` |
|
| `main` | (none) | `02.09.00` |
|
||||||
| `dev` | `-dev` | `02.09.01-dev` |
|
| `dev` | `-dev` | `02.09.01-dev` |
|
||||||
| `feature/*` | `-dev` | `02.09.01-dev` |
|
| `feature/*` | `-dev` | `02.09.01-dev` |
|
||||||
| `alpha` | `-alpha` | `02.09.01-alpha` |
|
| `alpha` | `-alpha` | `02.09.01-alpha` |
|
||||||
| `beta` | `-beta` | `02.09.01-beta` |
|
| `beta` | `-beta` | `02.09.01-beta` |
|
||||||
| `rc` | `-rc` | `02.09.01-rc` |
|
| `rc` | `-rc` | `02.09.01-rc` |
|
||||||
|
|
||||||
### Auto version bump
|
### Auto version bump
|
||||||
|
|
||||||
On every push to `dev`, `feature/*`, or `patch/*`:
|
On every push to `dev`, `feature/*`, or `patch/*`:
|
||||||
|
|
||||||
1. Patch version incremented
|
1. Patch version incremented
|
||||||
2. Stability suffix `-dev` applied
|
2. Stability suffix `-dev` applied
|
||||||
3. All version-bearing files updated (manifests, CHANGELOG, PHP headers, etc.)
|
3. All version-bearing files updated (manifests, CHANGELOG, PHP headers, etc.)
|
||||||
4. Commit created with `[skip ci]` to avoid loops
|
4. Commit created with `[skip ci]` to avoid loops
|
||||||
|
|
||||||
### Release version flow
|
### Release version flow
|
||||||
|
|
||||||
Version bumps happen at specific release events:
|
Version bumps happen at specific release events:
|
||||||
|
|
||||||
| Event | Bump | Example |
|
| Event | Bump | Example |
|
||||||
|-------|------|---------|
|
|-------|------|---------|
|
||||||
| Feature merged to dev | Patch bump after dev release | `02.09.01-dev` → release → `02.09.02-dev` |
|
| Feature merged to dev | Patch bump after dev release | `02.09.01-dev` → release → `02.09.02-dev` |
|
||||||
| Dev promoted to RC | Minor bump | `02.09.02-dev` → `02.10.00-rc` |
|
| Dev promoted to RC | Minor bump | `02.09.02-dev` → `02.10.00-rc` |
|
||||||
| RC merged to main | Minor bump | `02.10.00-rc` → `02.11.00` (stable) |
|
| RC merged to main | Minor bump | `02.10.00-rc` → `02.11.00` (stable) |
|
||||||
| Dev recreated from main | Patch bump | `02.11.00` → `02.11.01-dev` |
|
| Dev recreated from main | Patch bump | `02.11.00` → `02.11.01-dev` |
|
||||||
|
|
||||||
### Release stream copies
|
### Release stream copies
|
||||||
|
|
||||||
When a higher-stability release is published, copies are created for all lesser streams with the same base version:
|
When a higher-stability release is published, copies are created for all lesser streams with the same base version:
|
||||||
|
|
||||||
- **RC `02.10.00-rc`** also creates: `02.10.00-dev`, `02.10.00-alpha`, `02.10.00-beta`
|
- **RC `02.10.00-rc`** also creates: `02.10.00-dev`, `02.10.00-alpha`, `02.10.00-beta`
|
||||||
- **Stable `02.11.00`** also creates: `02.11.00-dev`, `02.11.00-alpha`, `02.11.00-beta`, `02.11.00-rc`
|
- **Stable `02.11.00`** also creates: `02.11.00-dev`, `02.11.00-alpha`, `02.11.00-beta`, `02.11.00-rc`
|
||||||
|
|
||||||
This ensures Joomla sites on ANY stability channel see the update (Joomla only shows versions higher than what's installed).
|
This ensures Joomla sites on ANY stability channel see the update (Joomla only shows versions higher than what's installed).
|
||||||
|
|
||||||
### Version files
|
### Version files
|
||||||
|
|
||||||
The version tools update all files containing version stamps:
|
The version tools update all files containing version stamps:
|
||||||
|
|
||||||
- `.mokogitea/manifest.xml` (canonical source)
|
- `.mokogitea/manifest.xml` (canonical source)
|
||||||
- Joomla XML manifests (`<version>` tag)
|
- Joomla XML manifests (`<version>` tag)
|
||||||
- `README.md`, `CHANGELOG.md` (`VERSION:` pattern)
|
- `README.md`, `CHANGELOG.md` (`VERSION:` pattern)
|
||||||
- `package.json`, `pyproject.toml`
|
- `package.json`, `pyproject.toml`
|
||||||
- Any text file with a `VERSION: XX.YY.ZZ` label
|
- Any text file with a `VERSION: XX.YY.ZZ` label
|
||||||
|
|
||||||
Files synced from other repos (with a `# REPO:` header) are not touched.
|
Files synced from other repos (with a `# REPO:` header) are not touched.
|
||||||
|
|
||||||
## Code Standards
|
## Code Standards
|
||||||
|
|
||||||
- **PHP**: PSR-12, tabs for indentation
|
- **PHP**: PSR-12, tabs for indentation
|
||||||
- **Copyright**: all files must include the Moko Consulting copyright header
|
- **Copyright**: all files must include the Moko Consulting copyright header
|
||||||
- **License**: SPDX identifier `GPL-3.0-or-later` (or as specified per repo)
|
- **License**: SPDX identifier `GPL-3.0-or-later` (or as specified per repo)
|
||||||
- **Attribution**: use `Authored-by: Moko Consulting` in commits, not individual names
|
- **Attribution**: use `Authored-by: Moko Consulting` in commits, not individual names
|
||||||
|
|
||||||
## Commit Messages
|
## Commit Messages
|
||||||
|
|
||||||
Use conventional commit format:
|
Use conventional commit format:
|
||||||
|
|
||||||
```
|
```
|
||||||
type(scope): short description
|
type(scope): short description
|
||||||
|
|
||||||
Optional body with context.
|
Optional body with context.
|
||||||
|
|
||||||
Authored-by: Moko Consulting
|
Authored-by: Moko Consulting
|
||||||
```
|
```
|
||||||
|
|
||||||
Types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `test`, `ci`
|
Types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `test`, `ci`
|
||||||
|
|
||||||
Special flags in commit messages:
|
Special flags in commit messages:
|
||||||
- `[skip ci]` — skip all CI workflows
|
- `[skip ci]` — skip all CI workflows
|
||||||
- `[skip bump]` — skip auto version bump only
|
- `[skip bump]` — skip auto version bump only
|
||||||
|
|
||||||
## Reporting Issues
|
## Reporting Issues
|
||||||
|
|
||||||
Use the repository's issue tracker with the appropriate template.
|
Use the repository's issue tracker with the appropriate template.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Moko Consulting <hello@mokoconsulting.tech>*
|
*Moko Consulting <hello@mokoconsulting.tech>*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# MokoJoomCross
|
# MokoJoomCross
|
||||||
|
|
||||||
<!-- VERSION: 01.00.26 -->
|
<!-- VERSION: 01.00.00-dev -->
|
||||||
|
|
||||||
Cross-posting Joomla content to social media, email marketing, and chat platforms for Joomla 5/6.
|
Cross-posting Joomla content to social media, email marketing, and chat platforms for Joomla 5/6.
|
||||||
|
|
||||||
|
|||||||
@@ -12,18 +12,6 @@
|
|||||||
<option value="0">JNO</option>
|
<option value="0">JNO</option>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
<field
|
|
||||||
name="post_on_first_publish_only"
|
|
||||||
type="radio"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_FIRST_PUBLISH_ONLY"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_FIRST_PUBLISH_ONLY_DESC"
|
|
||||||
default="0"
|
|
||||||
class="btn-group"
|
|
||||||
showon="auto_post_on_publish:1">
|
|
||||||
<option value="1">JYES</option>
|
|
||||||
<option value="0">JNO</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
<field
|
||||||
name="retry_max"
|
name="retry_max"
|
||||||
type="number"
|
type="number"
|
||||||
@@ -63,84 +51,4 @@
|
|||||||
rows="4"
|
rows="4"
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset name="evergreen" label="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN">
|
|
||||||
<field
|
|
||||||
name="evergreen_enabled"
|
|
||||||
type="radio"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_ENABLED"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_ENABLED_DESC"
|
|
||||||
default="1"
|
|
||||||
class="btn-group">
|
|
||||||
<option value="1">JYES</option>
|
|
||||||
<option value="0">JNO</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="evergreen_default_interval"
|
|
||||||
type="number"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL_DESC"
|
|
||||||
default="30"
|
|
||||||
min="1"
|
|
||||||
max="365"
|
|
||||||
showon="evergreen_enabled:1"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="evergreen_max_per_run"
|
|
||||||
type="number"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_MAX_PER_RUN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_MAX_PER_RUN_DESC"
|
|
||||||
default="3"
|
|
||||||
min="1"
|
|
||||||
max="20"
|
|
||||||
showon="evergreen_enabled:1"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset name="queue" label="COM_MOKOJOOMCROSS_CONFIG_QUEUE">
|
|
||||||
<field
|
|
||||||
name="queue_processing"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_QUEUE_PROCESSING"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_QUEUE_PROCESSING_DESC"
|
|
||||||
default="scheduler">
|
|
||||||
<option value="scheduler">COM_MOKOJOOMCROSS_CONFIG_QUEUE_SCHEDULER</option>
|
|
||||||
<option value="pageload">COM_MOKOJOOMCROSS_CONFIG_QUEUE_PAGELOAD</option>
|
|
||||||
<option value="both">COM_MOKOJOOMCROSS_CONFIG_QUEUE_BOTH</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="pageload_client"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_CLIENT"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_CLIENT_DESC"
|
|
||||||
default="both"
|
|
||||||
showon="queue_processing:pageload,both">
|
|
||||||
<option value="both">COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_BOTH</option>
|
|
||||||
<option value="admin">COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_ADMIN</option>
|
|
||||||
<option value="site">COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_SITE</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="pageload_interval"
|
|
||||||
type="number"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_INTERVAL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_INTERVAL_DESC"
|
|
||||||
default="300"
|
|
||||||
min="60"
|
|
||||||
max="3600"
|
|
||||||
showon="queue_processing:pageload,both"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset name="category_rules" label="COM_MOKOJOOMCROSS_CONFIG_CATEGORY_RULES">
|
|
||||||
<field
|
|
||||||
name="category_rules_note"
|
|
||||||
type="note"
|
|
||||||
label="COM_MOKOJOOMCROSS_CONFIG_CATEGORY_RULES_NOTE"
|
|
||||||
description="COM_MOKOJOOMCROSS_CONFIG_CATEGORY_RULES_NOTE_DESC"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<form>
|
|
||||||
<fields name="filter">
|
|
||||||
<field
|
|
||||||
name="search"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_FILTER_SEARCH"
|
|
||||||
hint="JSEARCH_FILTER"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="level"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_FILTER_LEVEL"
|
|
||||||
onchange="this.form.submit();">
|
|
||||||
<option value="">COM_MOKOJOOMCROSS_SELECT_LEVEL</option>
|
|
||||||
<option value="info">Info</option>
|
|
||||||
<option value="warning">Warning</option>
|
|
||||||
<option value="error">Error</option>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
|
|
||||||
<fields name="list">
|
|
||||||
<field
|
|
||||||
name="fullordering"
|
|
||||||
type="list"
|
|
||||||
label="JGLOBAL_SORT_BY"
|
|
||||||
default="a.created DESC"
|
|
||||||
onchange="this.form.submit();">
|
|
||||||
<option value="">JGLOBAL_SORT_BY</option>
|
|
||||||
<option value="a.created ASC">COM_MOKOJOOMCROSS_CREATED_ASC</option>
|
|
||||||
<option value="a.created DESC">COM_MOKOJOOMCROSS_CREATED_DESC</option>
|
|
||||||
<option value="a.level ASC">COM_MOKOJOOMCROSS_LEVEL_ASC</option>
|
|
||||||
<option value="a.level DESC">COM_MOKOJOOMCROSS_LEVEL_DESC</option>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
</form>
|
|
||||||
@@ -20,19 +20,6 @@
|
|||||||
<option value="failed">Failed</option>
|
<option value="failed">Failed</option>
|
||||||
<option value="scheduled">Scheduled</option>
|
<option value="scheduled">Scheduled</option>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
<field
|
|
||||||
name="service_id"
|
|
||||||
type="sql"
|
|
||||||
label="COM_MOKOJOOMCROSS_FILTER_SERVICE_TYPE"
|
|
||||||
onchange="this.form.submit();"
|
|
||||||
sql_select="id, CONCAT(title, ' (', service_type, ')') AS title"
|
|
||||||
sql_from="#__mokojoomcross_services"
|
|
||||||
key_field="id"
|
|
||||||
value_field="title"
|
|
||||||
sql_order="ordering ASC">
|
|
||||||
<option value="">COM_MOKOJOOMCROSS_SELECT_SERVICE</option>
|
|
||||||
</field>
|
|
||||||
</fields>
|
</fields>
|
||||||
|
|
||||||
<fields name="list">
|
<fields name="list">
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<form>
|
|
||||||
<fields name="filter">
|
|
||||||
<field
|
|
||||||
name="search"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_FILTER_SEARCH"
|
|
||||||
hint="JSEARCH_FILTER"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="published"
|
|
||||||
type="status"
|
|
||||||
label="JOPTION_SELECT_PUBLISHED"
|
|
||||||
onchange="this.form.submit();">
|
|
||||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="service_type"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_FILTER_SERVICE_TYPE"
|
|
||||||
onchange="this.form.submit();">
|
|
||||||
<option value="">COM_MOKOJOOMCROSS_SELECT_SERVICE_TYPE</option>
|
|
||||||
<option value="default">Default</option>
|
|
||||||
<option value="facebook">Facebook</option>
|
|
||||||
<option value="twitter">X / Twitter</option>
|
|
||||||
<option value="linkedin">LinkedIn</option>
|
|
||||||
<option value="mastodon">Mastodon</option>
|
|
||||||
<option value="bluesky">Bluesky</option>
|
|
||||||
<option value="mailchimp">Mailchimp</option>
|
|
||||||
<option value="telegram">Telegram</option>
|
|
||||||
<option value="discord">Discord</option>
|
|
||||||
<option value="slack">Slack</option>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
|
|
||||||
<fields name="list">
|
|
||||||
<field
|
|
||||||
name="fullordering"
|
|
||||||
type="list"
|
|
||||||
label="JGLOBAL_SORT_BY"
|
|
||||||
default="a.ordering ASC"
|
|
||||||
onchange="this.form.submit();">
|
|
||||||
<option value="">JGLOBAL_SORT_BY</option>
|
|
||||||
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
|
|
||||||
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
|
|
||||||
<option value="a.ordering ASC">JGLOBAL_ORDERING_ASC</option>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
</form>
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<form>
|
|
||||||
<fieldset name="details">
|
|
||||||
<field
|
|
||||||
name="id"
|
|
||||||
type="hidden"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="article_id"
|
|
||||||
type="sql"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_ARTICLE"
|
|
||||||
description="COM_MOKOJOOMCROSS_POST_ARTICLE_DESC"
|
|
||||||
required="true"
|
|
||||||
sql_select="id, title"
|
|
||||||
sql_from="#__content"
|
|
||||||
sql_filter="true"
|
|
||||||
sql_default_title="- Select Article -"
|
|
||||||
key_field="id"
|
|
||||||
value_field="title"
|
|
||||||
sql_order="title ASC"
|
|
||||||
>
|
|
||||||
<option value="">COM_MOKOJOOMCROSS_SELECT_ARTICLE</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="service_id"
|
|
||||||
type="sql"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_SERVICE"
|
|
||||||
description="COM_MOKOJOOMCROSS_POST_SERVICE_DESC"
|
|
||||||
required="true"
|
|
||||||
sql_select="id, CONCAT(title, ' (', service_type, ')') AS title"
|
|
||||||
sql_from="#__mokojoomcross_services"
|
|
||||||
sql_filter="true"
|
|
||||||
sql_default_title="- Select Service -"
|
|
||||||
sql_where="published = 1"
|
|
||||||
key_field="id"
|
|
||||||
value_field="title"
|
|
||||||
sql_order="ordering ASC"
|
|
||||||
>
|
|
||||||
<option value="">COM_MOKOJOOMCROSS_SELECT_SERVICE</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="message"
|
|
||||||
type="textarea"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_MESSAGE"
|
|
||||||
description="COM_MOKOJOOMCROSS_POST_MESSAGE_DESC"
|
|
||||||
rows="6"
|
|
||||||
cols="60"
|
|
||||||
required="true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="status"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_STATUS"
|
|
||||||
default="queued">
|
|
||||||
<option value="queued">COM_MOKOJOOMCROSS_STATUS_QUEUED</option>
|
|
||||||
<option value="scheduled">COM_MOKOJOOMCROSS_STATUS_SCHEDULED</option>
|
|
||||||
<option value="posted">COM_MOKOJOOMCROSS_STATUS_POSTED</option>
|
|
||||||
<option value="failed">COM_MOKOJOOMCROSS_STATUS_FAILED</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="scheduled_at"
|
|
||||||
type="calendar"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_SCHEDULED_AT"
|
|
||||||
description="COM_MOKOJOOMCROSS_POST_SCHEDULED_AT_DESC"
|
|
||||||
showtime="true"
|
|
||||||
format="%Y-%m-%d %H:%M:%S"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset name="readonly" label="COM_MOKOJOOMCROSS_POST_RESULTS">
|
|
||||||
<field
|
|
||||||
name="platform_post_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_PLATFORM_ID"
|
|
||||||
readonly="true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="error_message"
|
|
||||||
type="textarea"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_ERROR"
|
|
||||||
readonly="true"
|
|
||||||
rows="3"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="retry_count"
|
|
||||||
type="number"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_RETRY_COUNT"
|
|
||||||
readonly="true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="posted_at"
|
|
||||||
type="calendar"
|
|
||||||
label="COM_MOKOJOOMCROSS_POST_POSTED_AT"
|
|
||||||
readonly="true"
|
|
||||||
showtime="true"
|
|
||||||
format="%Y-%m-%d %H:%M:%S"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="created"
|
|
||||||
type="calendar"
|
|
||||||
label="JGLOBAL_CREATED"
|
|
||||||
readonly="true"
|
|
||||||
showtime="true"
|
|
||||||
format="%Y-%m-%d %H:%M:%S"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="modified"
|
|
||||||
type="calendar"
|
|
||||||
label="JGLOBAL_MODIFIED"
|
|
||||||
readonly="true"
|
|
||||||
showtime="true"
|
|
||||||
format="%Y-%m-%d %H:%M:%S"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
@@ -28,46 +28,15 @@
|
|||||||
required="true"
|
required="true"
|
||||||
default="">
|
default="">
|
||||||
<option value="">COM_MOKOJOOMCROSS_SELECT_SERVICE_TYPE</option>
|
<option value="">COM_MOKOJOOMCROSS_SELECT_SERVICE_TYPE</option>
|
||||||
<!-- Social Media -->
|
|
||||||
<option value="facebook">Facebook / Meta</option>
|
<option value="facebook">Facebook / Meta</option>
|
||||||
<option value="twitter">X / Twitter</option>
|
<option value="twitter">X / Twitter</option>
|
||||||
<option value="linkedin">LinkedIn</option>
|
<option value="linkedin">LinkedIn</option>
|
||||||
<option value="mastodon">Mastodon</option>
|
<option value="mastodon">Mastodon</option>
|
||||||
<option value="bluesky">Bluesky</option>
|
<option value="bluesky">Bluesky</option>
|
||||||
<option value="threads">Threads (Meta)</option>
|
<option value="mailchimp">Mailchimp</option>
|
||||||
<option value="pinterest">Pinterest</option>
|
|
||||||
<option value="reddit">Reddit</option>
|
|
||||||
<option value="tumblr">Tumblr</option>
|
|
||||||
<option value="tiktok">TikTok</option>
|
|
||||||
<option value="nostr">Nostr</option>
|
|
||||||
<option value="activitypub">ActivityPub (Fediverse)</option>
|
|
||||||
<!-- Chat / Messaging -->
|
|
||||||
<option value="telegram">Telegram</option>
|
<option value="telegram">Telegram</option>
|
||||||
<option value="discord">Discord</option>
|
<option value="discord">Discord</option>
|
||||||
<option value="slack">Slack</option>
|
<option value="slack">Slack</option>
|
||||||
<option value="teams">Microsoft Teams</option>
|
|
||||||
<option value="googlechat">Google Chat</option>
|
|
||||||
<option value="whatsapp">WhatsApp Business</option>
|
|
||||||
<option value="matrix">Matrix / Element</option>
|
|
||||||
<option value="ntfy">Ntfy (Push Notifications)</option>
|
|
||||||
<!-- Email / Newsletter -->
|
|
||||||
<option value="mailchimp">Mailchimp</option>
|
|
||||||
<option value="sendgrid">SendGrid</option>
|
|
||||||
<option value="brevo">Brevo (Sendinblue)</option>
|
|
||||||
<option value="convertkit">ConvertKit</option>
|
|
||||||
<option value="constantcontact">Constant Contact</option>
|
|
||||||
<!-- Publishing / Blogging -->
|
|
||||||
<option value="medium">Medium</option>
|
|
||||||
<option value="wordpress">WordPress</option>
|
|
||||||
<option value="devto">Dev.to</option>
|
|
||||||
<option value="ghost">Ghost</option>
|
|
||||||
<option value="hashnode">Hashnode</option>
|
|
||||||
<option value="blogger">Google Blogger</option>
|
|
||||||
<!-- Business -->
|
|
||||||
<option value="googlebusiness">Google Business Profile</option>
|
|
||||||
<!-- Other -->
|
|
||||||
<option value="webhook">Generic Webhook</option>
|
|
||||||
<option value="rssfeed">RSS Feed</option>
|
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
<field
|
<field
|
||||||
@@ -86,825 +55,14 @@
|
|||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<!-- ============================================================ -->
|
|
||||||
<!-- Per-service credential fields using showon -->
|
|
||||||
<!-- ============================================================ -->
|
|
||||||
|
|
||||||
<!-- Mode selector for services with default bot support -->
|
|
||||||
<fieldset name="credentials" label="COM_MOKOJOOMCROSS_FIELDSET_CREDENTIALS">
|
<fieldset name="credentials" label="COM_MOKOJOOMCROSS_FIELDSET_CREDENTIALS">
|
||||||
|
|
||||||
<field
|
<field
|
||||||
name="cred_mode"
|
name="credentials"
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_FIELD_CRED_MODE"
|
|
||||||
description="COM_MOKOJOOMCROSS_FIELD_CRED_MODE_DESC"
|
|
||||||
default="default"
|
|
||||||
showon="service_type:telegram,discord,slack,teams,facebook,threads">
|
|
||||||
<option value="default">COM_MOKOJOOMCROSS_CRED_MODE_DEFAULT</option>
|
|
||||||
<option value="custom">COM_MOKOJOOMCROSS_CRED_MODE_CUSTOM</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<!-- ======== TELEGRAM ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_telegram_chat_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TELEGRAM_CHAT_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TELEGRAM_CHAT_ID_DESC"
|
|
||||||
showon="service_type:telegram"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_telegram_bot_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TELEGRAM_BOT_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TELEGRAM_BOT_TOKEN_DESC"
|
|
||||||
showon="service_type:telegram[AND]cred_mode:custom"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== DISCORD ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_discord_webhook_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_DISCORD_WEBHOOK"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_DISCORD_WEBHOOK_DESC"
|
|
||||||
showon="service_type:discord[AND]cred_mode:custom"
|
|
||||||
size="80"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_discord_username"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_DISCORD_USERNAME"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_DISCORD_USERNAME_DESC"
|
|
||||||
showon="service_type:discord"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_discord_avatar_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_DISCORD_AVATAR"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_DISCORD_AVATAR_DESC"
|
|
||||||
showon="service_type:discord"
|
|
||||||
size="80"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== SLACK ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_slack_webhook_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_SLACK_WEBHOOK"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_SLACK_WEBHOOK_DESC"
|
|
||||||
showon="service_type:slack[AND]cred_mode:custom"
|
|
||||||
size="80"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== MICROSOFT TEAMS ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_teams_webhook_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TEAMS_WEBHOOK"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TEAMS_WEBHOOK_DESC"
|
|
||||||
showon="service_type:teams[AND]cred_mode:custom"
|
|
||||||
size="80"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== GOOGLE CHAT ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_googlechat_webhook_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GOOGLECHAT_WEBHOOK"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_GOOGLECHAT_WEBHOOK_DESC"
|
|
||||||
showon="service_type:googlechat"
|
|
||||||
size="80"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== FACEBOOK ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_facebook_page_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_FACEBOOK_PAGE_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_FACEBOOK_PAGE_ID_DESC"
|
|
||||||
showon="service_type:facebook"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_facebook_page_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_FACEBOOK_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_FACEBOOK_TOKEN_DESC"
|
|
||||||
showon="service_type:facebook[AND]cred_mode:custom"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== THREADS ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_threads_user_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_THREADS_USER_ID"
|
|
||||||
showon="service_type:threads"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_threads_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_THREADS_TOKEN"
|
|
||||||
showon="service_type:threads[AND]cred_mode:custom"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== TWITTER / X (OAuth 1.0a — 4 keys required for posting) ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_twitter_api_key"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TWITTER_API_KEY"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TWITTER_API_KEY_DESC"
|
|
||||||
showon="service_type:twitter"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_twitter_api_secret"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TWITTER_API_SECRET"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TWITTER_API_SECRET_DESC"
|
|
||||||
showon="service_type:twitter"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_twitter_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN_DESC"
|
|
||||||
showon="service_type:twitter"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_twitter_access_token_secret"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN_SECRET"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN_SECRET_DESC"
|
|
||||||
showon="service_type:twitter"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== LINKEDIN ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_linkedin_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_LINKEDIN_TOKEN"
|
|
||||||
showon="service_type:linkedin"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_linkedin_organization_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_LINKEDIN_ORG_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_LINKEDIN_ORG_ID_DESC"
|
|
||||||
showon="service_type:linkedin"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_linkedin_refresh_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_LINKEDIN_REFRESH_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_LINKEDIN_REFRESH_TOKEN_DESC"
|
|
||||||
showon="service_type:linkedin"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== MASTODON ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_mastodon_instance_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MASTODON_INSTANCE"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_MASTODON_INSTANCE_DESC"
|
|
||||||
showon="service_type:mastodon"
|
|
||||||
size="40"
|
|
||||||
default="https://mastodon.social"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_mastodon_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MASTODON_TOKEN"
|
|
||||||
showon="service_type:mastodon"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== BLUESKY ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_bluesky_handle"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BLUESKY_HANDLE"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_BLUESKY_HANDLE_DESC"
|
|
||||||
showon="service_type:bluesky"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_bluesky_app_password"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BLUESKY_APP_PWD"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_BLUESKY_APP_PWD_DESC"
|
|
||||||
showon="service_type:bluesky"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_bluesky_pds_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BLUESKY_PDS_URL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_BLUESKY_PDS_URL_DESC"
|
|
||||||
showon="service_type:bluesky"
|
|
||||||
size="40"
|
|
||||||
default="https://bsky.social"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== WHATSAPP ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_whatsapp_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WHATSAPP_TOKEN"
|
|
||||||
showon="service_type:whatsapp"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_whatsapp_phone_number_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WHATSAPP_PHONE_ID"
|
|
||||||
showon="service_type:whatsapp"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_whatsapp_recipient"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WHATSAPP_RECIPIENT"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_WHATSAPP_RECIPIENT_DESC"
|
|
||||||
showon="service_type:whatsapp"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== MAILCHIMP ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_mailchimp_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_KEY"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_KEY_DESC"
|
|
||||||
showon="service_type:mailchimp"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_mailchimp_list_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_LIST"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_LIST_DESC"
|
|
||||||
showon="service_type:mailchimp"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_mailchimp_from_name"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_NAME"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_NAME_DESC"
|
|
||||||
showon="service_type:mailchimp"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_mailchimp_from_email"
|
|
||||||
type="email"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_EMAIL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_EMAIL_DESC"
|
|
||||||
showon="service_type:mailchimp"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== SENDGRID ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_sendgrid_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_SENDGRID_KEY"
|
|
||||||
showon="service_type:sendgrid"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_sendgrid_list_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_SENDGRID_LIST"
|
|
||||||
showon="service_type:sendgrid"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_sendgrid_from_email"
|
|
||||||
type="email"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_EMAIL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_EMAIL_DESC"
|
|
||||||
showon="service_type:sendgrid"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_sendgrid_from_name"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_NAME"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_NAME_DESC"
|
|
||||||
showon="service_type:sendgrid"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== GENERIC WEBHOOK ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_webhook_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_URL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_WEBHOOK_URL_DESC"
|
|
||||||
showon="service_type:webhook"
|
|
||||||
size="80"
|
|
||||||
required="true"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_webhook_method"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_METHOD"
|
|
||||||
showon="service_type:webhook"
|
|
||||||
default="POST">
|
|
||||||
<option value="POST">POST</option>
|
|
||||||
<option value="PUT">PUT</option>
|
|
||||||
</field>
|
|
||||||
<field
|
|
||||||
name="cred_webhook_auth_type"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_AUTH_TYPE"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_WEBHOOK_AUTH_TYPE_DESC"
|
|
||||||
showon="service_type:webhook"
|
|
||||||
default="none">
|
|
||||||
<option value="none">COM_MOKOJOOMCROSS_WEBHOOK_AUTH_NONE</option>
|
|
||||||
<option value="bearer">COM_MOKOJOOMCROSS_WEBHOOK_AUTH_BEARER</option>
|
|
||||||
<option value="basic">COM_MOKOJOOMCROSS_WEBHOOK_AUTH_BASIC</option>
|
|
||||||
</field>
|
|
||||||
<field
|
|
||||||
name="cred_webhook_bearer_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_BEARER_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_WEBHOOK_BEARER_TOKEN_DESC"
|
|
||||||
showon="service_type:webhook[AND]cred_webhook_auth_type:bearer"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_webhook_basic_username"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_BASIC_USER"
|
|
||||||
showon="service_type:webhook[AND]cred_webhook_auth_type:basic"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_webhook_basic_password"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_BASIC_PWD"
|
|
||||||
showon="service_type:webhook[AND]cred_webhook_auth_type:basic"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_webhook_content_type"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WEBHOOK_CONTENT_TYPE"
|
|
||||||
showon="service_type:webhook"
|
|
||||||
default="json">
|
|
||||||
<option value="json">application/json</option>
|
|
||||||
<option value="form">application/x-www-form-urlencoded</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<!-- ======== MATRIX ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_matrix_homeserver"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MATRIX_HOMESERVER"
|
|
||||||
showon="service_type:matrix"
|
|
||||||
size="40"
|
|
||||||
default="https://matrix.org"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_matrix_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MATRIX_TOKEN"
|
|
||||||
showon="service_type:matrix"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_matrix_room_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MATRIX_ROOM"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_MATRIX_ROOM_DESC"
|
|
||||||
showon="service_type:matrix"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== NTFY ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_ntfy_server_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_NTFY_SERVER"
|
|
||||||
showon="service_type:ntfy"
|
|
||||||
size="40"
|
|
||||||
default="https://ntfy.sh"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_ntfy_topic"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_NTFY_TOPIC"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_NTFY_TOPIC_DESC"
|
|
||||||
showon="service_type:ntfy"
|
|
||||||
size="40"
|
|
||||||
required="true"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_ntfy_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_NTFY_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_NTFY_TOKEN_DESC"
|
|
||||||
showon="service_type:ntfy"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== WORDPRESS ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_wordpress_site_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WP_SITE"
|
|
||||||
showon="service_type:wordpress"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_wordpress_username"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WP_USER"
|
|
||||||
showon="service_type:wordpress"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_wordpress_app_password"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WP_APP_PWD"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_WP_APP_PWD_DESC"
|
|
||||||
showon="service_type:wordpress"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_wordpress_default_status"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_WP_DEFAULT_STATUS"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_WP_DEFAULT_STATUS_DESC"
|
|
||||||
showon="service_type:wordpress"
|
|
||||||
default="draft">
|
|
||||||
<option value="draft">COM_MOKOJOOMCROSS_STATUS_DRAFT</option>
|
|
||||||
<option value="publish">COM_MOKOJOOMCROSS_STATUS_PUBLISH</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<!-- ======== MEDIUM ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_medium_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_MEDIUM_TOKEN"
|
|
||||||
showon="service_type:medium"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== DEV.TO ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_devto_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_DEVTO_KEY"
|
|
||||||
showon="service_type:devto"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_devto_organization_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_DEVTO_ORG_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_DEVTO_ORG_ID_DESC"
|
|
||||||
showon="service_type:devto"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== GHOST ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_ghost_site_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GHOST_SITE"
|
|
||||||
showon="service_type:ghost"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_ghost_admin_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GHOST_KEY"
|
|
||||||
showon="service_type:ghost"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_ghost_default_status"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GHOST_DEFAULT_STATUS"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_GHOST_DEFAULT_STATUS_DESC"
|
|
||||||
showon="service_type:ghost"
|
|
||||||
default="draft">
|
|
||||||
<option value="draft">COM_MOKOJOOMCROSS_STATUS_DRAFT</option>
|
|
||||||
<option value="published">COM_MOKOJOOMCROSS_STATUS_PUBLISHED</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<!-- ======== REDDIT ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_reddit_client_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_REDDIT_CLIENT_ID"
|
|
||||||
showon="service_type:reddit"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_reddit_client_secret"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_REDDIT_SECRET"
|
|
||||||
showon="service_type:reddit"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_reddit_username"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_REDDIT_USER"
|
|
||||||
showon="service_type:reddit"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_reddit_password"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_REDDIT_PASSWORD"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_REDDIT_PASSWORD_DESC"
|
|
||||||
showon="service_type:reddit"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_reddit_subreddit"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_REDDIT_SUBREDDIT"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_REDDIT_SUBREDDIT_DESC"
|
|
||||||
showon="service_type:reddit"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== PINTEREST ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_pinterest_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_PINTEREST_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_PINTEREST_TOKEN_DESC"
|
|
||||||
showon="service_type:pinterest"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_pinterest_board_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_PINTEREST_BOARD"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_PINTEREST_BOARD_DESC"
|
|
||||||
showon="service_type:pinterest"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== TUMBLR ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_tumblr_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TUMBLR_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TUMBLR_TOKEN_DESC"
|
|
||||||
showon="service_type:tumblr"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_tumblr_blog_name"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TUMBLR_BLOG"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TUMBLR_BLOG_DESC"
|
|
||||||
showon="service_type:tumblr"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== TIKTOK ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_tiktok_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TIKTOK_TOKEN"
|
|
||||||
showon="service_type:tiktok"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_tiktok_refresh_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TIKTOK_REFRESH_TOKEN"
|
|
||||||
showon="service_type:tiktok"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_tiktok_open_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_TIKTOK_OPEN_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_TIKTOK_OPEN_ID_DESC"
|
|
||||||
showon="service_type:tiktok"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== NOSTR ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_nostr_private_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_NOSTR_PRIVKEY"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_NOSTR_PRIVKEY_DESC"
|
|
||||||
showon="service_type:nostr"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_nostr_relays"
|
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label="COM_MOKOJOOMCROSS_CRED_NOSTR_RELAYS"
|
label="COM_MOKOJOOMCROSS_FIELD_CREDENTIALS"
|
||||||
description="COM_MOKOJOOMCROSS_CRED_NOSTR_RELAYS_DESC"
|
description="COM_MOKOJOOMCROSS_FIELD_CREDENTIALS_DESC"
|
||||||
showon="service_type:nostr"
|
rows="6"
|
||||||
rows="3"
|
filter="raw"
|
||||||
cols="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== ACTIVITYPUB (Fediverse) ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_activitypub_instance_url"
|
|
||||||
type="url"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_INSTANCE"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_INSTANCE_DESC"
|
|
||||||
showon="service_type:activitypub"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_activitypub_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_TOKEN"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_TOKEN_DESC"
|
|
||||||
showon="service_type:activitypub"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== BREVO (Sendinblue) ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_brevo_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BREVO_KEY"
|
|
||||||
showon="service_type:brevo"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_brevo_list_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BREVO_LIST"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_BREVO_LIST_DESC"
|
|
||||||
showon="service_type:brevo"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_brevo_sender_email"
|
|
||||||
type="email"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BREVO_SENDER_EMAIL"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_BREVO_SENDER_EMAIL_DESC"
|
|
||||||
showon="service_type:brevo"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_brevo_sender_name"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BREVO_SENDER_NAME"
|
|
||||||
showon="service_type:brevo"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== CONVERTKIT ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_convertkit_api_key"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_CONVERTKIT_KEY"
|
|
||||||
showon="service_type:convertkit"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_convertkit_api_secret"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_CONVERTKIT_SECRET"
|
|
||||||
showon="service_type:convertkit"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== CONSTANT CONTACT ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_constantcontact_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_TOKEN"
|
|
||||||
showon="service_type:constantcontact"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_constantcontact_refresh_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_REFRESH_TOKEN"
|
|
||||||
showon="service_type:constantcontact"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_constantcontact_list_ids"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_LISTS"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_LISTS_DESC"
|
|
||||||
showon="service_type:constantcontact"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== HASHNODE ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_hashnode_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_HASHNODE_TOKEN"
|
|
||||||
showon="service_type:hashnode"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_hashnode_publication_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_HASHNODE_PUB_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_HASHNODE_PUB_ID_DESC"
|
|
||||||
showon="service_type:hashnode"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== GOOGLE BLOGGER ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_blogger_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BLOGGER_TOKEN"
|
|
||||||
showon="service_type:blogger"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_blogger_refresh_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BLOGGER_REFRESH_TOKEN"
|
|
||||||
showon="service_type:blogger"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_blogger_blog_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_BLOGGER_BLOG_ID"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_BLOGGER_BLOG_ID_DESC"
|
|
||||||
showon="service_type:blogger"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== GOOGLE BUSINESS PROFILE ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_googlebusiness_access_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GBUSINESS_TOKEN"
|
|
||||||
showon="service_type:googlebusiness"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_googlebusiness_refresh_token"
|
|
||||||
type="password"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GBUSINESS_REFRESH_TOKEN"
|
|
||||||
showon="service_type:googlebusiness"
|
|
||||||
size="60"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_googlebusiness_location_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GBUSINESS_LOCATION"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_GBUSINESS_LOCATION_DESC"
|
|
||||||
showon="service_type:googlebusiness"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_googlebusiness_account_id"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_GBUSINESS_ACCOUNT"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_GBUSINESS_ACCOUNT_DESC"
|
|
||||||
showon="service_type:googlebusiness"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- ======== RSS FEED ======== -->
|
|
||||||
<field
|
|
||||||
name="cred_rssfeed_title"
|
|
||||||
type="text"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_RSSFEED_TITLE"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_RSSFEED_TITLE_DESC"
|
|
||||||
showon="service_type:rssfeed"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="cred_rssfeed_max_items"
|
|
||||||
type="number"
|
|
||||||
label="COM_MOKOJOOMCROSS_CRED_RSSFEED_MAX_ITEMS"
|
|
||||||
description="COM_MOKOJOOMCROSS_CRED_RSSFEED_MAX_ITEMS_DESC"
|
|
||||||
showon="service_type:rssfeed"
|
|
||||||
default="50"
|
|
||||||
min="1"
|
|
||||||
max="500"
|
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<form>
|
|
||||||
<fieldset name="details">
|
|
||||||
<field
|
|
||||||
name="id"
|
|
||||||
type="hidden"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="title"
|
|
||||||
type="text"
|
|
||||||
label="JGLOBAL_TITLE"
|
|
||||||
required="true"
|
|
||||||
size="40"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="service_type"
|
|
||||||
type="list"
|
|
||||||
label="COM_MOKOJOOMCROSS_FIELD_SERVICE_TYPE"
|
|
||||||
description="COM_MOKOJOOMCROSS_TEMPLATE_SERVICE_TYPE_DESC"
|
|
||||||
default="default">
|
|
||||||
<option value="default">COM_MOKOJOOMCROSS_TEMPLATE_TYPE_DEFAULT</option>
|
|
||||||
<option value="facebook">Facebook</option>
|
|
||||||
<option value="twitter">X / Twitter</option>
|
|
||||||
<option value="linkedin">LinkedIn</option>
|
|
||||||
<option value="mastodon">Mastodon</option>
|
|
||||||
<option value="bluesky">Bluesky</option>
|
|
||||||
<option value="mailchimp">Mailchimp</option>
|
|
||||||
<option value="telegram">Telegram</option>
|
|
||||||
<option value="discord">Discord</option>
|
|
||||||
<option value="slack">Slack</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="template_body"
|
|
||||||
type="textarea"
|
|
||||||
label="COM_MOKOJOOMCROSS_TEMPLATE_BODY"
|
|
||||||
description="COM_MOKOJOOMCROSS_TEMPLATE_BODY_DESC"
|
|
||||||
rows="10"
|
|
||||||
cols="60"
|
|
||||||
required="true"
|
|
||||||
filter="raw"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="published"
|
|
||||||
type="list"
|
|
||||||
label="JSTATUS"
|
|
||||||
default="1">
|
|
||||||
<option value="1">JPUBLISHED</option>
|
|
||||||
<option value="0">JUNPUBLISHED</option>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field
|
|
||||||
name="ordering"
|
|
||||||
type="ordering"
|
|
||||||
label="JFIELD_ORDERING_LABEL"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
@@ -58,456 +58,3 @@ COM_MOKOJOOMCROSS_CONFIG_LOG_RETENTION="Log Retention (days)"
|
|||||||
COM_MOKOJOOMCROSS_CONFIG_LOG_RETENTION_DESC="Number of days to keep activity logs"
|
COM_MOKOJOOMCROSS_CONFIG_LOG_RETENTION_DESC="Number of days to keep activity logs"
|
||||||
COM_MOKOJOOMCROSS_CONFIG_DEFAULT_TEMPLATE="Default Message Template"
|
COM_MOKOJOOMCROSS_CONFIG_DEFAULT_TEMPLATE="Default Message Template"
|
||||||
COM_MOKOJOOMCROSS_CONFIG_DEFAULT_TEMPLATE_DESC="Default template for cross-posts. Placeholders: {title}, {url}, {introtext}, {image}, {category}, {author}"
|
COM_MOKOJOOMCROSS_CONFIG_DEFAULT_TEMPLATE_DESC="Default template for cross-posts. Placeholders: {title}, {url}, {introtext}, {image}, {category}, {author}"
|
||||||
|
|
||||||
; Table headings
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_STATUS="Status"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_ARTICLE="Article"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_SERVICE="Service"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_MESSAGE="Message"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_POSTED_AT="Posted"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_CREATED="Created"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_LEVEL="Level"
|
|
||||||
COM_MOKOJOOMCROSS_HEADING_MODE="Mode"
|
|
||||||
|
|
||||||
; Dashboard
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_RECENT_ACTIVITY="Recent Activity"
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_NO_RECENT="No recent activity."
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_TOTAL_POSTS="Total Posts"
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_PAGELOAD_WARNING_TITLE="Page-load queue processing is active"
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_PAGELOAD_WARNING="You are using page-load processing for the cross-post queue. This is a fallback method and may be unreliable on low-traffic sites. For production use, switch to Joomla Scheduled Tasks: create a task of type <strong>MokoJoomCross - Process Queue</strong> in System → Scheduled Tasks, then set queue processing to <strong>Scheduler only</strong> in component options."
|
|
||||||
|
|
||||||
; Evergreen Configuration
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN="Evergreen Re-sharing"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_ENABLED="Enable Evergreen"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_ENABLED_DESC="Allow articles marked as evergreen to be automatically re-shared on a recurring schedule."
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL="Default Interval (days)"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL_DESC="Default number of days between re-shares when no per-article interval is set."
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_MAX_PER_RUN="Max Re-shares Per Run"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_EVERGREEN_MAX_PER_RUN_DESC="Maximum number of evergreen articles to re-share in a single queue processing run. Prevents flooding platforms."
|
|
||||||
|
|
||||||
; Queue Processing Configuration
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_QUEUE="Queue Processing"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_QUEUE_PROCESSING="Processing Method"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_QUEUE_PROCESSING_DESC="How queued posts, retries, and scheduled posts are processed. Scheduler (recommended) uses Joomla's built-in Task Scheduler. Page-load piggybacks on page requests."
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_QUEUE_SCHEDULER="Scheduler only (recommended)"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_QUEUE_PAGELOAD="Page-load only (fallback)"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_QUEUE_BOTH="Both (scheduler + page-load)"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_CLIENT="Page-load Client"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_CLIENT_DESC="Which Joomla application triggers page-load processing."
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_BOTH="Backend and Frontend"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_ADMIN="Backend only"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_SITE="Frontend only"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_INTERVAL="Page-load Interval (seconds)"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_PAGELOAD_INTERVAL_DESC="Minimum seconds between page-load queue runs. Lower = more responsive but more DB queries per page load."
|
|
||||||
|
|
||||||
; Submenu (extended)
|
|
||||||
COM_MOKOJOOMCROSS_SUBMENU_TEMPLATES="Templates"
|
|
||||||
|
|
||||||
; Template Management
|
|
||||||
COM_MOKOJOOMCROSS_TEMPLATE_BODY="Template Body"
|
|
||||||
COM_MOKOJOOMCROSS_TEMPLATE_BODY_DESC="Message template with placeholders. Use the reference panel on the right for available placeholders."
|
|
||||||
COM_MOKOJOOMCROSS_TEMPLATE_SERVICE_TYPE_DESC="Which platform this template is for. 'Default' is the fallback when no platform-specific template exists."
|
|
||||||
COM_MOKOJOOMCROSS_TEMPLATE_TYPE_DEFAULT="Default (fallback)"
|
|
||||||
COM_MOKOJOOMCROSS_TEMPLATE_PREVIEW="Preview"
|
|
||||||
COM_MOKOJOOMCROSS_TEMPLATE_PLACEHOLDERS="Available Placeholders"
|
|
||||||
|
|
||||||
; Placeholders
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_TITLE="Article title"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_URL="Article URL"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_INTROTEXT="Intro text (280 chars, no HTML)"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_FULLTEXT="Full text (500 chars, no HTML)"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_IMAGE="Intro image URL"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_CATEGORY="Category name"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_AUTHOR="Author name"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_DATE="Publish date (YYYY-MM-DD)"
|
|
||||||
|
|
||||||
; Logs
|
|
||||||
COM_MOKOJOOMCROSS_FILTER_LEVEL="Level"
|
|
||||||
COM_MOKOJOOMCROSS_SELECT_LEVEL="- Select Level -"
|
|
||||||
COM_MOKOJOOMCROSS_LEVEL_ASC="Level ascending"
|
|
||||||
COM_MOKOJOOMCROSS_LEVEL_DESC="Level descending"
|
|
||||||
|
|
||||||
; Analytics Dashboard
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_SERVICE_BREAKDOWN="Posts by Service"
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_TOP_ARTICLES="Most Cross-Posted Articles"
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_SUCCESS_RATE="Success Rate"
|
|
||||||
|
|
||||||
; OAuth
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_NO_SERVICE="No service specified for OAuth authorization."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_SERVICE_NOT_FOUND="Service not found."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_NO_CLIENT_ID="No OAuth Client ID configured for %s. Set it in Extensions → Plugins → MokoJoomCross - %s."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_NOT_SUPPORTED="OAuth is not supported for %s."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_PLATFORM_ERROR="Platform returned error: %s"
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_INVALID_CALLBACK="Invalid OAuth callback — missing code or state."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_INVALID_STATE="Invalid OAuth state parameter."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_TOKEN_ERROR="Token exchange failed: %s"
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_SUCCESS="%s connected successfully! Access token stored."
|
|
||||||
|
|
||||||
; Post edit
|
|
||||||
COM_MOKOJOOMCROSS_NEW_POST="New Post"
|
|
||||||
COM_MOKOJOOMCROSS_EDIT_POST="Edit Post"
|
|
||||||
COM_MOKOJOOMCROSS_POST_ARTICLE="Article"
|
|
||||||
COM_MOKOJOOMCROSS_POST_ARTICLE_DESC="The Joomla article to cross-post."
|
|
||||||
COM_MOKOJOOMCROSS_SELECT_ARTICLE="- Select Article -"
|
|
||||||
COM_MOKOJOOMCROSS_POST_SERVICE="Service"
|
|
||||||
COM_MOKOJOOMCROSS_POST_SERVICE_DESC="The service to post to."
|
|
||||||
COM_MOKOJOOMCROSS_SELECT_SERVICE="- Select Service -"
|
|
||||||
COM_MOKOJOOMCROSS_POST_MESSAGE="Message"
|
|
||||||
COM_MOKOJOOMCROSS_POST_MESSAGE_DESC="The message to send to the platform. Use template placeholders or write a custom message."
|
|
||||||
COM_MOKOJOOMCROSS_POST_STATUS="Status"
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_QUEUED="Queued"
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_SCHEDULED="Scheduled"
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_POSTED="Posted"
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_FAILED="Failed"
|
|
||||||
COM_MOKOJOOMCROSS_POST_SCHEDULED_AT="Scheduled Date/Time"
|
|
||||||
COM_MOKOJOOMCROSS_POST_SCHEDULED_AT_DESC="When to send this post. Leave empty to process immediately. Set a future date to schedule."
|
|
||||||
COM_MOKOJOOMCROSS_POST_RESULTS="Post Results"
|
|
||||||
COM_MOKOJOOMCROSS_POST_PLATFORM_ID="Platform Post ID"
|
|
||||||
COM_MOKOJOOMCROSS_POST_ERROR="Error Message"
|
|
||||||
COM_MOKOJOOMCROSS_POST_RETRY_COUNT="Retry Count"
|
|
||||||
COM_MOKOJOOMCROSS_POST_POSTED_AT="Posted At"
|
|
||||||
COM_MOKOJOOMCROSS_POST_CREATE_HELP="Create a manual cross-post. Select an article and service, write your message, and optionally set a scheduled date. Leave the schedule empty to queue for immediate processing."
|
|
||||||
COM_MOKOJOOMCROSS_POST_REQUEUE="Re-queue for Posting"
|
|
||||||
COM_MOKOJOOMCROSS_POST_REQUEUE_HELP="Reset this post to queued status so it will be processed again on the next queue run."
|
|
||||||
|
|
||||||
; Service edit
|
|
||||||
COM_MOKOJOOMCROSS_NEW_SERVICE="New Service"
|
|
||||||
COM_MOKOJOOMCROSS_EDIT_SERVICE="Edit Service"
|
|
||||||
COM_MOKOJOOMCROSS_SERVICE_DETAILS="Service Details"
|
|
||||||
COM_MOKOJOOMCROSS_CREDENTIALS_HELP="Fill in the connection details for the selected platform. Fields change based on the service type you choose above."
|
|
||||||
|
|
||||||
; Credential mode
|
|
||||||
COM_MOKOJOOMCROSS_FIELD_CRED_MODE="Connection Mode"
|
|
||||||
COM_MOKOJOOMCROSS_FIELD_CRED_MODE_DESC="Default uses the pre-configured MokoWaaS account. Custom lets you use your own API credentials."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MODE_DEFAULT="Default (MokoWaaS)"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MODE_CUSTOM="Custom (your own credentials)"
|
|
||||||
|
|
||||||
; Telegram
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TELEGRAM_CHAT_ID="Chat ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TELEGRAM_CHAT_ID_DESC="Telegram channel, group, or user chat ID. Channel IDs start with -100. Get yours from @userinfobot."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TELEGRAM_BOT_TOKEN="Bot Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TELEGRAM_BOT_TOKEN_DESC="Your custom Telegram bot token from @BotFather. Only needed in Custom mode."
|
|
||||||
|
|
||||||
; Discord
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DISCORD_WEBHOOK="Webhook URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DISCORD_WEBHOOK_DESC="Discord channel webhook URL. Create one in Channel Settings → Integrations → Webhooks."
|
|
||||||
|
|
||||||
; Slack
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SLACK_WEBHOOK="Webhook URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SLACK_WEBHOOK_DESC="Slack Incoming Webhook URL. Create one at api.slack.com/apps."
|
|
||||||
|
|
||||||
; Teams
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TEAMS_WEBHOOK="Webhook URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TEAMS_WEBHOOK_DESC="Microsoft Teams Incoming Webhook URL. Create in channel Connectors."
|
|
||||||
|
|
||||||
; Google Chat
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GOOGLECHAT_WEBHOOK="Webhook URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GOOGLECHAT_WEBHOOK_DESC="Google Chat space webhook URL."
|
|
||||||
|
|
||||||
; Facebook
|
|
||||||
COM_MOKOJOOMCROSS_CRED_FACEBOOK_PAGE_ID="Facebook Page ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_FACEBOOK_PAGE_ID_DESC="Your Facebook Page numeric ID. Find it in Page Settings → About."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_FACEBOOK_TOKEN="Page Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_FACEBOOK_TOKEN_DESC="Long-lived Page Access Token. Use the Authorize button below or generate via Meta Business Suite."
|
|
||||||
|
|
||||||
; Threads
|
|
||||||
COM_MOKOJOOMCROSS_CRED_THREADS_USER_ID="Threads User ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_THREADS_TOKEN="Access Token"
|
|
||||||
|
|
||||||
; Twitter (OAuth 1.0a)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_API_KEY="API Key (Consumer Key)"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_API_KEY_DESC="Consumer Key from the Twitter Developer Portal → Keys and Tokens."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_API_SECRET="API Secret (Consumer Secret)"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_API_SECRET_DESC="Consumer Secret from the Twitter Developer Portal → Keys and Tokens."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN_DESC="User access token from the Developer Portal → Keys and Tokens → Authentication Tokens."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN_SECRET="Access Token Secret"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TWITTER_ACCESS_TOKEN_SECRET_DESC="User access token secret from the Developer Portal → Keys and Tokens → Authentication Tokens."
|
|
||||||
|
|
||||||
; LinkedIn
|
|
||||||
COM_MOKOJOOMCROSS_CRED_LINKEDIN_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_LINKEDIN_ORG_ID="Organization ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_LINKEDIN_ORG_ID_DESC="LinkedIn Company Page ID. Leave empty to post as yourself."
|
|
||||||
|
|
||||||
; Mastodon
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MASTODON_INSTANCE="Instance URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MASTODON_INSTANCE_DESC="Your Mastodon server (e.g. https://mastodon.social)"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MASTODON_TOKEN="Access Token"
|
|
||||||
|
|
||||||
; Bluesky
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLUESKY_HANDLE="Handle"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLUESKY_HANDLE_DESC="Your Bluesky handle (e.g. user.bsky.social)"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLUESKY_APP_PWD="App Password"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLUESKY_APP_PWD_DESC="Generate in Bluesky Settings → Advanced → App Passwords."
|
|
||||||
|
|
||||||
; WhatsApp
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WHATSAPP_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WHATSAPP_PHONE_ID="Phone Number ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WHATSAPP_RECIPIENT="Recipient Number"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WHATSAPP_RECIPIENT_DESC="Phone number to send to, with country code (e.g. +1234567890)"
|
|
||||||
|
|
||||||
; Mailchimp
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_KEY="API Key"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_KEY_DESC="Mailchimp API key (ends with -us1, -us2, etc.)"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_LIST="Audience/List ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_LIST_DESC="The audience to send campaigns to. Find in Audience → Settings → Audience ID."
|
|
||||||
|
|
||||||
; SendGrid
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SENDGRID_KEY="API Key"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SENDGRID_LIST="Contact List ID"
|
|
||||||
|
|
||||||
; Webhook
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_URL="Webhook URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_URL_DESC="The URL to send article data to. Works with Zapier, IFTTT, n8n, Make, or any custom endpoint."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_METHOD="HTTP Method"
|
|
||||||
|
|
||||||
; Matrix
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MATRIX_HOMESERVER="Homeserver URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MATRIX_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MATRIX_ROOM="Room ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MATRIX_ROOM_DESC="Matrix room ID (e.g. !abc123:matrix.org)"
|
|
||||||
|
|
||||||
; Ntfy
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NTFY_SERVER="Server URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NTFY_TOPIC="Topic Name"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NTFY_TOPIC_DESC="The notification topic (e.g. my-site-updates). Subscribers use this to receive push notifications."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NTFY_TOKEN="Auth Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NTFY_TOKEN_DESC="Optional authentication token if your ntfy server requires it."
|
|
||||||
|
|
||||||
; WordPress
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WP_SITE="WordPress Site URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WP_USER="Username"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WP_APP_PWD="Application Password"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WP_APP_PWD_DESC="Generate in WordPress → Users → Profile → Application Passwords."
|
|
||||||
|
|
||||||
; Medium
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MEDIUM_TOKEN="Integration Token"
|
|
||||||
|
|
||||||
; Dev.to
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DEVTO_KEY="API Key"
|
|
||||||
|
|
||||||
; Ghost
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GHOST_SITE="Ghost Site URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GHOST_KEY="Admin API Key"
|
|
||||||
|
|
||||||
; Reddit
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_CLIENT_ID="App Client ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_SECRET="App Secret"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_USER="Reddit Username"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_SUBREDDIT="Subreddit"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_SUBREDDIT_DESC="Subreddit to post to (without r/ prefix)"
|
|
||||||
|
|
||||||
; Authorize / OAuth
|
|
||||||
COM_MOKOJOOMCROSS_AUTHORIZE_BUTTON="Connect to %s"
|
|
||||||
COM_MOKOJOOMCROSS_AUTHORIZE_HELP="Click to open the authorization page. You'll be redirected back after granting access. Your token will be saved automatically."
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_HELP_TITLE="Authorization Required"
|
|
||||||
COM_MOKOJOOMCROSS_OAUTH_HELP_BODY="This service requires OAuth authorization. Save the service first, then click the Connect button below to authorize access."
|
|
||||||
|
|
||||||
; LinkedIn (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_LINKEDIN_REFRESH_TOKEN="Refresh Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_LINKEDIN_REFRESH_TOKEN_DESC="OAuth refresh token for automatic access token renewal."
|
|
||||||
|
|
||||||
; Bluesky (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLUESKY_PDS_URL="PDS URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLUESKY_PDS_URL_DESC="Personal Data Server URL. Default is https://bsky.social. Only change for self-hosted PDS."
|
|
||||||
|
|
||||||
; Discord (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DISCORD_USERNAME="Display Name Override"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DISCORD_USERNAME_DESC="Override the webhook's default display name. Leave empty to use the webhook name."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DISCORD_AVATAR="Avatar URL Override"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DISCORD_AVATAR_DESC="Override the webhook's default avatar with a custom image URL."
|
|
||||||
|
|
||||||
; Mailchimp (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_NAME="From Name"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_NAME_DESC="Sender name for campaigns. Leave empty to use the audience default."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_EMAIL="From Email"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_MAILCHIMP_FROM_EMAIL_DESC="Sender email for campaigns. Must be a verified sending domain."
|
|
||||||
|
|
||||||
; SendGrid (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_EMAIL="From Email"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_EMAIL_DESC="Verified sender email address for Single Sends."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_NAME="From Name"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_SENDGRID_FROM_NAME_DESC="Display name for the sender."
|
|
||||||
|
|
||||||
; Reddit (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_PASSWORD="Account Password"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_REDDIT_PASSWORD_DESC="Required for Reddit script-type OAuth. The password for the Reddit account."
|
|
||||||
|
|
||||||
; WordPress (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WP_DEFAULT_STATUS="Default Post Status"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WP_DEFAULT_STATUS_DESC="Whether cross-posted articles appear as drafts or are published immediately."
|
|
||||||
|
|
||||||
; Dev.to (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DEVTO_ORG_ID="Organization ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_DEVTO_ORG_ID_DESC="Optional. Publish under a Dev.to organization instead of your personal account."
|
|
||||||
|
|
||||||
; Ghost (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GHOST_DEFAULT_STATUS="Default Post Status"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GHOST_DEFAULT_STATUS_DESC="Whether cross-posted articles are saved as drafts or published immediately."
|
|
||||||
|
|
||||||
; Status options (shared)
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_DRAFT="Draft"
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_PUBLISH="Publish"
|
|
||||||
COM_MOKOJOOMCROSS_STATUS_PUBLISHED="Published"
|
|
||||||
|
|
||||||
; Pinterest
|
|
||||||
COM_MOKOJOOMCROSS_CRED_PINTEREST_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_PINTEREST_TOKEN_DESC="Pinterest API v5 access token from the Developer Portal."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_PINTEREST_BOARD="Board ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_PINTEREST_BOARD_DESC="The board to pin to. Find the ID in the board URL or via the API."
|
|
||||||
|
|
||||||
; Tumblr
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TUMBLR_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TUMBLR_TOKEN_DESC="Tumblr OAuth access token."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TUMBLR_BLOG="Blog Name"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TUMBLR_BLOG_DESC="Your Tumblr blog name (e.g. myblog — without .tumblr.com)."
|
|
||||||
|
|
||||||
; TikTok
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TIKTOK_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TIKTOK_REFRESH_TOKEN="Refresh Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TIKTOK_OPEN_ID="Open ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_TIKTOK_OPEN_ID_DESC="Your TikTok Open ID from the developer app authorization."
|
|
||||||
|
|
||||||
; Nostr
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NOSTR_PRIVKEY="Private Key"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NOSTR_PRIVKEY_DESC="Nostr private key in hex or nsec format. Used to sign events."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NOSTR_RELAYS="Relay URLs"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_NOSTR_RELAYS_DESC="Comma-separated list of relay WebSocket URLs (e.g. wss://relay.damus.io, wss://nos.lol)."
|
|
||||||
|
|
||||||
; ActivityPub
|
|
||||||
COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_INSTANCE="Instance URL"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_INSTANCE_DESC="Fediverse instance URL (Pleroma, Akkoma, Misskey, Pixelfed, etc.)."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_ACTIVITYPUB_TOKEN_DESC="API access token from the instance's developer settings."
|
|
||||||
|
|
||||||
; Brevo (Sendinblue)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BREVO_KEY="API Key"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BREVO_LIST="Contact List ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BREVO_LIST_DESC="Brevo contact list ID to send campaigns to."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BREVO_SENDER_EMAIL="Sender Email"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BREVO_SENDER_EMAIL_DESC="Must be a verified sender in your Brevo account."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BREVO_SENDER_NAME="Sender Name"
|
|
||||||
|
|
||||||
; ConvertKit
|
|
||||||
COM_MOKOJOOMCROSS_CRED_CONVERTKIT_KEY="API Key"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_CONVERTKIT_SECRET="API Secret"
|
|
||||||
|
|
||||||
; Constant Contact
|
|
||||||
COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_REFRESH_TOKEN="Refresh Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_LISTS="Contact List IDs"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_CONSTANTCONTACT_LISTS_DESC="Comma-separated list IDs to include in the campaign."
|
|
||||||
|
|
||||||
; Hashnode
|
|
||||||
COM_MOKOJOOMCROSS_CRED_HASHNODE_TOKEN="Personal Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_HASHNODE_PUB_ID="Publication ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_HASHNODE_PUB_ID_DESC="Your Hashnode publication ID. Find in Dashboard → General settings."
|
|
||||||
|
|
||||||
; Google Blogger
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLOGGER_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLOGGER_REFRESH_TOKEN="Refresh Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLOGGER_BLOG_ID="Blog ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_BLOGGER_BLOG_ID_DESC="Numeric Blog ID from Blogger settings or the Blogger API."
|
|
||||||
|
|
||||||
; Google Business Profile
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GBUSINESS_TOKEN="Access Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GBUSINESS_REFRESH_TOKEN="Refresh Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GBUSINESS_LOCATION="Location ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GBUSINESS_LOCATION_DESC="Google Business location ID (e.g. locations/1234567890)."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GBUSINESS_ACCOUNT="Account ID"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_GBUSINESS_ACCOUNT_DESC="Google Business account ID (e.g. accounts/1234567890)."
|
|
||||||
|
|
||||||
; RSS Feed
|
|
||||||
COM_MOKOJOOMCROSS_CRED_RSSFEED_TITLE="Feed Title"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_RSSFEED_TITLE_DESC="Title for the generated RSS feed. Defaults to the site name."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_RSSFEED_MAX_ITEMS="Max Feed Items"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_RSSFEED_MAX_ITEMS_DESC="Maximum number of items to include in the feed."
|
|
||||||
|
|
||||||
; Webhook (additional)
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_AUTH_TYPE="Authentication"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_AUTH_TYPE_DESC="Authentication method for the webhook endpoint."
|
|
||||||
COM_MOKOJOOMCROSS_WEBHOOK_AUTH_NONE="None"
|
|
||||||
COM_MOKOJOOMCROSS_WEBHOOK_AUTH_BEARER="Bearer Token"
|
|
||||||
COM_MOKOJOOMCROSS_WEBHOOK_AUTH_BASIC="Basic Auth"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_BEARER_TOKEN="Bearer Token"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_BEARER_TOKEN_DESC="Authentication token sent as Authorization: Bearer {token}."
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_BASIC_USER="Username"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_BASIC_PWD="Password"
|
|
||||||
COM_MOKOJOOMCROSS_CRED_WEBHOOK_CONTENT_TYPE="Content Type"
|
|
||||||
|
|
||||||
; Service help link
|
|
||||||
COM_MOKOJOOMCROSS_SERVICE_HELP_LINK="%s Setup Guide"
|
|
||||||
|
|
||||||
; Setup help panel
|
|
||||||
COM_MOKOJOOMCROSS_SETUP_HELP_TITLE="How to set up"
|
|
||||||
COM_MOKOJOOMCROSS_SETUP_HELP_INTRO="Setting up a new service is easy:"
|
|
||||||
COM_MOKOJOOMCROSS_SETUP_STEP1="Choose a service type from the dropdown"
|
|
||||||
COM_MOKOJOOMCROSS_SETUP_STEP2="Fill in the connection details that appear"
|
|
||||||
COM_MOKOJOOMCROSS_SETUP_STEP3="For OAuth services, save first, then click Connect"
|
|
||||||
COM_MOKOJOOMCROSS_SETUP_STEP4="Set status to Published and save"
|
|
||||||
|
|
||||||
; Test Connection
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_TITLE="Test Connection"
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_DESC="Verify that your credentials are valid and the service is reachable."
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_BUTTON="Test Connection"
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_TESTING="Testing..."
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_SUCCESS="Connection successful"
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_FAILED="Connection failed"
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_ERROR="Could not reach the server. Please try again."
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_NO_SERVICE="No service specified for test."
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_NOT_FOUND="Service record not found."
|
|
||||||
COM_MOKOJOOMCROSS_TEST_CONNECTION_NO_PLUGIN="No service plugin available for type '%s'."
|
|
||||||
|
|
||||||
; Bulk Queue Actions
|
|
||||||
COM_MOKOJOOMCROSS_TOOLBAR_RETRY_FAILED="Retry Failed"
|
|
||||||
COM_MOKOJOOMCROSS_TOOLBAR_PURGE_POSTED="Purge Posted"
|
|
||||||
COM_MOKOJOOMCROSS_POSTS_N_RETRIED="%d failed post(s) re-queued for retry."
|
|
||||||
COM_MOKOJOOMCROSS_POSTS_N_RETRIED_1="1 failed post re-queued for retry."
|
|
||||||
COM_MOKOJOOMCROSS_POSTS_N_PURGED="%d posted record(s) purged."
|
|
||||||
COM_MOKOJOOMCROSS_POSTS_N_PURGED_1="1 posted record purged."
|
|
||||||
COM_MOKOJOOMCROSS_POSTS_N_SCHEDULED="%d post(s) scheduled."
|
|
||||||
COM_MOKOJOOMCROSS_POSTS_NO_ITEM_SELECTED="No posts selected."
|
|
||||||
COM_MOKOJOOMCROSS_SCHEDULE_NO_DATE="Please select a date and time for scheduling."
|
|
||||||
COM_MOKOJOOMCROSS_TOOLBAR_SCHEDULE="Schedule"
|
|
||||||
COM_MOKOJOOMCROSS_TOOLBAR_RETRY_SELECTED="Retry Selected"
|
|
||||||
|
|
||||||
; Queue Depth Warning
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_QUEUE_DEPTH_WARNING_TITLE="Large queue backlog"
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_QUEUE_DEPTH_WARNING="There are %d posts waiting in the queue. Please verify that the Joomla Task Scheduler is running and the MokoJoomCross scheduled task is enabled in System → Scheduled Tasks."
|
|
||||||
|
|
||||||
; First-Publish-Only
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_FIRST_PUBLISH_ONLY="First Publish Only"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_FIRST_PUBLISH_ONLY_DESC="When enabled, articles are only cross-posted on their first save as published. Subsequent edits to already-published articles will not trigger new cross-posts."
|
|
||||||
|
|
||||||
; Trend Chart
|
|
||||||
COM_MOKOJOOMCROSS_DASHBOARD_TREND_CHART="Daily Post Trend"
|
|
||||||
|
|
||||||
; Date Range Period Filter
|
|
||||||
COM_MOKOJOOMCROSS_PERIOD_7_DAYS="Last 7 days"
|
|
||||||
COM_MOKOJOOMCROSS_PERIOD_30_DAYS="Last 30 days"
|
|
||||||
COM_MOKOJOOMCROSS_PERIOD_90_DAYS="Last 90 days"
|
|
||||||
COM_MOKOJOOMCROSS_PERIOD_ALL_TIME="All time"
|
|
||||||
|
|
||||||
; Hashtag Placeholders
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_TAGS="Article tags (comma-separated)"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_HASHTAGS="Article tags as hashtags (#Tag1 #Tag2)"
|
|
||||||
COM_MOKOJOOMCROSS_PLACEHOLDER_CUSTOM_FIELD="Custom field value (replace xxx with field name)"
|
|
||||||
|
|
||||||
; CSV Export
|
|
||||||
COM_MOKOJOOMCROSS_EXPORT_CSV="Export CSV"
|
|
||||||
|
|
||||||
; Service Stats (drill-down)
|
|
||||||
COM_MOKOJOOMCROSS_SERVICESTATS_RECENT_POSTS="Recent Posts"
|
|
||||||
COM_MOKOJOOMCROSS_SERVICESTATS_NO_POSTS="No posts for this service yet."
|
|
||||||
COM_MOKOJOOMCROSS_SERVICESTATS_TOP_ARTICLES="Top Articles for This Service"
|
|
||||||
|
|
||||||
; API Dispatch
|
|
||||||
COM_MOKOJOOMCROSS_DISPATCH_MISSING_ARTICLE="Missing or invalid article_id in request body."
|
|
||||||
COM_MOKOJOOMCROSS_DISPATCH_INVALID_SERVICES="service_ids must be a non-empty array of service IDs."
|
|
||||||
COM_MOKOJOOMCROSS_DISPATCH_ARTICLE_NOT_FOUND="Article not found."
|
|
||||||
COM_MOKOJOOMCROSS_DISPATCH_NO_SERVICES="No enabled services found matching the request."
|
|
||||||
|
|
||||||
; Category Rules
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_CATEGORY_RULES="Category Rules"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_CATEGORY_RULES_NOTE="Category Routing"
|
|
||||||
COM_MOKOJOOMCROSS_CONFIG_CATEGORY_RULES_NOTE_DESC="Category routing rules let you map Joomla categories to specific cross-post services. When rules exist for a category, only those services receive posts. When no rules exist, all services are used (default behaviour). Rules are managed in the database table #__mokojoomcross_category_rules. A full admin UI will be added in a future release."
|
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ COM_MOKOJOOMCROSS_DESCRIPTION="Cross-posting Joomla content to social media, ema
|
|||||||
COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD="Dashboard"
|
COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD="Dashboard"
|
||||||
COM_MOKOJOOMCROSS_SUBMENU_POSTS="Post Queue"
|
COM_MOKOJOOMCROSS_SUBMENU_POSTS="Post Queue"
|
||||||
COM_MOKOJOOMCROSS_SUBMENU_SERVICES="Services"
|
COM_MOKOJOOMCROSS_SUBMENU_SERVICES="Services"
|
||||||
COM_MOKOJOOMCROSS_SUBMENU_TEMPLATES="Templates"
|
|
||||||
COM_MOKOJOOMCROSS_SUBMENU_LOGS="Activity Logs"
|
COM_MOKOJOOMCROSS_SUBMENU_LOGS="Activity Logs"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="component" method="upgrade">
|
<extension type="component" method="upgrade">
|
||||||
<name>com_mokojoomcross</name>
|
<name>com_mokojoomcross</name>
|
||||||
<version>01.00.26-dev</version>
|
<version>01.00.00-dev</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
@@ -48,7 +48,6 @@
|
|||||||
<menu link="option=com_mokojoomcross&view=dashboard">COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD</menu>
|
<menu link="option=com_mokojoomcross&view=dashboard">COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD</menu>
|
||||||
<menu link="option=com_mokojoomcross&view=posts">COM_MOKOJOOMCROSS_SUBMENU_POSTS</menu>
|
<menu link="option=com_mokojoomcross&view=posts">COM_MOKOJOOMCROSS_SUBMENU_POSTS</menu>
|
||||||
<menu link="option=com_mokojoomcross&view=services">COM_MOKOJOOMCROSS_SUBMENU_SERVICES</menu>
|
<menu link="option=com_mokojoomcross&view=services">COM_MOKOJOOMCROSS_SUBMENU_SERVICES</menu>
|
||||||
<menu link="option=com_mokojoomcross&view=templates">COM_MOKOJOOMCROSS_SUBMENU_TEMPLATES</menu>
|
|
||||||
<menu link="option=com_mokojoomcross&view=logs">COM_MOKOJOOMCROSS_SUBMENU_LOGS</menu>
|
<menu link="option=com_mokojoomcross&view=logs">COM_MOKOJOOMCROSS_SUBMENU_LOGS</menu>
|
||||||
</submenu>
|
</submenu>
|
||||||
<files>
|
<files>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `#__mokojoomcross_posts` (
|
|||||||
`scheduled_at` datetime DEFAULT NULL COMMENT 'When to post (NULL = immediately)',
|
`scheduled_at` datetime DEFAULT NULL COMMENT 'When to post (NULL = immediately)',
|
||||||
`posted_at` datetime DEFAULT NULL COMMENT 'When actually posted',
|
`posted_at` datetime DEFAULT NULL COMMENT 'When actually posted',
|
||||||
`retry_count` int(10) unsigned NOT NULL DEFAULT 0,
|
`retry_count` int(10) unsigned NOT NULL DEFAULT 0,
|
||||||
`error_message` text NOT NULL,
|
`error_message` text NOT NULL DEFAULT '',
|
||||||
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
@@ -76,30 +76,4 @@ INSERT INTO `#__mokojoomcross_templates` (`service_type`, `title`, `template_bod
|
|||||||
('default', 'Default Template', '{title}\n\n{introtext}\n\n{url}', 1, 1, NOW()),
|
('default', 'Default Template', '{title}\n\n{introtext}\n\n{url}', 1, 1, NOW()),
|
||||||
('twitter', 'Twitter/X Default', '{title}\n\n{url}', 1, 2, NOW()),
|
('twitter', 'Twitter/X Default', '{title}\n\n{url}', 1, 2, NOW()),
|
||||||
('mastodon', 'Mastodon Default', '{title}\n\n{introtext}\n\n{url}\n\n#Joomla', 1, 3, NOW()),
|
('mastodon', 'Mastodon Default', '{title}\n\n{introtext}\n\n{url}\n\n#Joomla', 1, 3, NOW()),
|
||||||
('mailchimp', 'Mailchimp Default', '<h1>{title}</h1>\n<p>{introtext}</p>\n<p><a href=\"{url}\">Read more</a></p>', 1, 4, NOW()),
|
('mailchimp', 'Mailchimp Default', '<h1>{title}</h1>\n<p>{introtext}</p>\n<p><a href=\"{url}\">Read more</a></p>', 1, 4, NOW());
|
||||||
('telegram', 'Telegram Default', '<b>{title}</b>\n\n{introtext}\n\n<a href=\"{url}\">Read more</a>', 1, 5, NOW()),
|
|
||||||
('discord', 'Discord Default', '**{title}**\n\n{introtext}\n\n{url}', 1, 6, NOW()),
|
|
||||||
('slack', 'Slack Default', '*{title}*\n\n{introtext}\n\n{url}', 1, 7, NOW()),
|
|
||||||
('facebook', 'Facebook Default', '{title}\n\n{introtext}\n\n{url}', 1, 8, NOW()),
|
|
||||||
('linkedin', 'LinkedIn Default', '{title}\n\n{introtext}\n\n{url}', 1, 9, NOW()),
|
|
||||||
('bluesky', 'Bluesky Default', '{title}\n\n{url}', 1, 10, NOW()),
|
|
||||||
('threads', 'Threads Default', '{title}\n\n{introtext}\n\n{url}', 1, 11, NOW()),
|
|
||||||
('teams', 'Teams Default', '**{title}**\n\n{introtext}\n\n[Read more]({url})', 1, 12, NOW()),
|
|
||||||
('medium', 'Medium Default', '{title}\n\n{introtext}\n\n{url}', 1, 13, NOW()),
|
|
||||||
('wordpress', 'WordPress Default', '{title}\n\n{introtext}\n\n{url}', 1, 14, NOW()),
|
|
||||||
('webhook', 'Webhook Default', '{title}\n\n{introtext}\n\n{url}', 1, 15, NOW()),
|
|
||||||
('sendgrid', 'SendGrid Default', '<h1>{title}</h1>\n<p>{introtext}</p>\n<p><a href=\"{url}\">Read more</a></p>', 1, 16, NOW()),
|
|
||||||
('brevo', 'Brevo Default', '<h1>{title}</h1>\n<p>{introtext}</p>\n<p><a href=\"{url}\">Read more</a></p>', 1, 17, NOW()),
|
|
||||||
('ntfy', 'Ntfy Default', '{title}: {introtext}', 1, 18, NOW()),
|
|
||||||
('reddit', 'Reddit Default', '{title}', 1, 19, NOW()),
|
|
||||||
('pinterest', 'Pinterest Default', '{title} - {introtext}', 1, 20, NOW());
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `#__mokojoomcross_category_rules` (
|
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`category_id` int(10) unsigned NOT NULL,
|
|
||||||
`service_id` int(10) unsigned NOT NULL,
|
|
||||||
`published` tinyint(1) NOT NULL DEFAULT 1,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `idx_category_service` (`category_id`, `service_id`),
|
|
||||||
KEY `idx_category` (`category_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
-- MokoJoomCross 01.01.00 — Category routing rules
|
|
||||||
-- Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `#__mokojoomcross_category_rules` (
|
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`category_id` int(10) unsigned NOT NULL,
|
|
||||||
`service_id` int(10) unsigned NOT NULL,
|
|
||||||
`published` tinyint(1) NOT NULL DEFAULT 1,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `idx_category_service` (`category_id`, `service_id`),
|
|
||||||
KEY `idx_category` (`category_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\Controller\BaseController;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\MigrationHelper;
|
|
||||||
|
|
||||||
class DashboardController extends BaseController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run Perfect Publisher Pro migration.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function migrate(): void
|
|
||||||
{
|
|
||||||
// Check ACL
|
|
||||||
if (!$this->app->getIdentity()->authorise('mokojoomcross.migrate', 'com_mokojoomcross')) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false),
|
|
||||||
Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = MigrationHelper::migrate();
|
|
||||||
|
|
||||||
if (!empty($result['errors'])) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_MIGRATION_ERROR', implode('; ', $result['errors'])),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_MIGRATION_SUCCESS', $result['migrated'], $result['skipped']),
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,351 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Component\ComponentHelper;
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\Controller\BaseController;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\CMS\Uri\Uri;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Service\MokoJoomCrossServiceInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* REST API controller for dispatching cross-posts.
|
|
||||||
*
|
|
||||||
* Endpoint: POST /api/index.php/v1/mokojoomcross/dispatch
|
|
||||||
*
|
|
||||||
* JSON body:
|
|
||||||
* {
|
|
||||||
* "article_id": 123,
|
|
||||||
* "service_ids": [1, 2, 3] // optional — omit to post to all enabled services
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Returns JSON with the created post IDs and status.
|
|
||||||
*
|
|
||||||
* Authentication is handled by Joomla's API application (token or session).
|
|
||||||
* The webservices plugin routes POST requests here via the API router.
|
|
||||||
*/
|
|
||||||
class DispatchController extends BaseController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Dispatch cross-posts for an article to one or more services.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function dispatch(): void
|
|
||||||
{
|
|
||||||
$app = $this->app;
|
|
||||||
|
|
||||||
// Enforce POST method — this is a state-changing action endpoint
|
|
||||||
if (strtoupper($this->input->getMethod()) !== 'POST') {
|
|
||||||
$this->sendJsonResponse(['error' => 'Method not allowed. Use POST.'], 405);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read JSON body
|
|
||||||
$input = json_decode(file_get_contents('php://input'), true) ?: [];
|
|
||||||
$articleId = (int) ($input['article_id'] ?? 0);
|
|
||||||
$serviceIds = $input['service_ids'] ?? null;
|
|
||||||
|
|
||||||
if ($articleId < 1) {
|
|
||||||
$this->sendJsonResponse(['error' => Text::_('COM_MOKOJOOMCROSS_DISPATCH_MISSING_ARTICLE')], 400);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate service_ids if provided
|
|
||||||
if ($serviceIds !== null) {
|
|
||||||
if (!is_array($serviceIds) || empty($serviceIds)) {
|
|
||||||
$this->sendJsonResponse(['error' => Text::_('COM_MOKOJOOMCROSS_DISPATCH_INVALID_SERVICES')], 400);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$serviceIds = array_map('intval', $serviceIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
// Load the article
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__content'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $articleId);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$article = $db->loadObject();
|
|
||||||
|
|
||||||
if (!$article) {
|
|
||||||
$this->sendJsonResponse(['error' => Text::_('COM_MOKOJOOMCROSS_DISPATCH_ARTICLE_NOT_FOUND')], 404);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load enabled services, optionally filtered by service_ids
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('published') . ' = 1')
|
|
||||||
->order($db->quoteName('ordering') . ' ASC');
|
|
||||||
|
|
||||||
if ($serviceIds !== null) {
|
|
||||||
$query->where($db->quoteName('id') . ' IN (' . implode(',', $serviceIds) . ')');
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$services = $db->loadObjectList() ?: [];
|
|
||||||
|
|
||||||
if (empty($services)) {
|
|
||||||
$this->sendJsonResponse(['error' => Text::_('COM_MOKOJOOMCROSS_DISPATCH_NO_SERVICES')], 404);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import service plugins and build type-to-plugin map.
|
|
||||||
// In Joomla 5+ with SubscriberInterface, plugins receive the Event object
|
|
||||||
// as their first argument. When they do $services[] = $this, they append to
|
|
||||||
// the Event via ArrayAccess at numeric indices starting at 1.
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
|
|
||||||
$servicePlugins = [];
|
|
||||||
$event = new \Joomla\Event\Event('onMokoJoomCrossGetServices', [$servicePlugins]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$app->getDispatcher()->dispatch('onMokoJoomCrossGetServices', $event);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Dispatcher may not be available
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read plugins back from the Event's ArrayAccess indices
|
|
||||||
$idx = 1;
|
|
||||||
|
|
||||||
while (isset($event[$idx])) {
|
|
||||||
$servicePlugins[] = $event[$idx];
|
|
||||||
$idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pluginMap = [];
|
|
||||||
|
|
||||||
foreach ($servicePlugins as $plugin) {
|
|
||||||
if ($plugin instanceof MokoJoomCrossServiceInterface) {
|
|
||||||
$pluginMap[$plugin->getServiceType()] = $plugin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render template and create queue entries (same logic as system plugin dispatchCrossPost)
|
|
||||||
$componentParams = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
$createdIds = [];
|
|
||||||
$skipped = [];
|
|
||||||
|
|
||||||
// Build article URL
|
|
||||||
$articleUrl = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$articleUrl .= '&catid=' . $article->catid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract intro image for media
|
|
||||||
$media = [];
|
|
||||||
$images = json_decode($article->images ?? '{}');
|
|
||||||
|
|
||||||
if (!empty($images->image_intro)) {
|
|
||||||
$media[] = Uri::root() . ltrim($images->image_intro, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($services as $service) {
|
|
||||||
// Duplicate guard — skip if article already posted/queued for this service
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('article_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . (int) $service->id)
|
|
||||||
->where($db->quoteName('status') . ' IN (' . $db->quote('queued') . ',' . $db->quote('posted') . ',' . $db->quote('posting') . ')');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
if ((int) $db->loadResult() > 0) {
|
|
||||||
$skipped[] = [
|
|
||||||
'service_id' => (int) $service->id,
|
|
||||||
'service_type' => $service->service_type,
|
|
||||||
'reason' => 'duplicate',
|
|
||||||
];
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render template
|
|
||||||
$message = $this->renderTemplate($db, $article, $service, $componentParams);
|
|
||||||
|
|
||||||
// Create queue entry
|
|
||||||
$post = (object) [
|
|
||||||
'article_id' => (int) $article->id,
|
|
||||||
'service_id' => (int) $service->id,
|
|
||||||
'status' => 'queued',
|
|
||||||
'message' => $message,
|
|
||||||
'platform_post_id' => '',
|
|
||||||
'platform_response' => '',
|
|
||||||
'error_message' => '',
|
|
||||||
'retry_count' => 0,
|
|
||||||
'created' => $now,
|
|
||||||
'modified' => $now,
|
|
||||||
];
|
|
||||||
|
|
||||||
$db->insertObject('#__mokojoomcross_posts', $post);
|
|
||||||
$postId = (int) $db->insertid();
|
|
||||||
|
|
||||||
$createdIds[] = [
|
|
||||||
'post_id' => $postId,
|
|
||||||
'service_id' => (int) $service->id,
|
|
||||||
'service_type' => $service->service_type,
|
|
||||||
'status' => 'queued',
|
|
||||||
];
|
|
||||||
|
|
||||||
// Write log entry
|
|
||||||
$log = (object) [
|
|
||||||
'post_id' => $postId,
|
|
||||||
'service_id' => (int) $service->id,
|
|
||||||
'level' => 'info',
|
|
||||||
'message' => sprintf('API dispatch: queued article %d to %s', $article->id, $service->service_type),
|
|
||||||
'context' => '{}',
|
|
||||||
'created' => $now,
|
|
||||||
];
|
|
||||||
|
|
||||||
$db->insertObject('#__mokojoomcross_logs', $log);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sendJsonResponse([
|
|
||||||
'article_id' => (int) $article->id,
|
|
||||||
'dispatched' => $createdIds,
|
|
||||||
'skipped' => $skipped,
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the message template for a service (simplified version of system plugin logic).
|
|
||||||
*/
|
|
||||||
private function renderTemplate($db, object $article, object $service, $componentParams): string
|
|
||||||
{
|
|
||||||
// Try service-specific template first, fall back to default
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('template_body'))
|
|
||||||
->from($db->quoteName('#__mokojoomcross_templates'))
|
|
||||||
->where($db->quoteName('published') . ' = 1')
|
|
||||||
->where('(' . $db->quoteName('service_type') . ' = ' . $db->quote($service->service_type)
|
|
||||||
. ' OR ' . $db->quoteName('service_type') . ' = ' . $db->quote('default') . ')')
|
|
||||||
->order('CASE WHEN ' . $db->quoteName('service_type') . ' = '
|
|
||||||
. $db->quote($service->service_type) . ' THEN 0 ELSE 1 END')
|
|
||||||
->setLimit(1);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$template = $db->loadResult() ?: ($componentParams->get('default_template', "{title}\n\n{url}"));
|
|
||||||
|
|
||||||
// Build article URL
|
|
||||||
$url = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$url .= '&catid=' . $article->catid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve category name
|
|
||||||
$categoryName = '';
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('title'))
|
|
||||||
->from($db->quoteName('#__categories'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->catid);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$categoryName = $db->loadResult() ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve author name
|
|
||||||
$authorName = '';
|
|
||||||
|
|
||||||
if (!empty($article->created_by)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('name'))
|
|
||||||
->from($db->quoteName('#__users'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->created_by);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$authorName = $db->loadResult() ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract intro image
|
|
||||||
$introImage = '';
|
|
||||||
$images = json_decode($article->images ?? '{}');
|
|
||||||
|
|
||||||
if (!empty($images->image_intro)) {
|
|
||||||
$introImage = Uri::root() . ltrim($images->image_intro, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve article tags
|
|
||||||
$tagNames = [];
|
|
||||||
|
|
||||||
if (!empty($article->id)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('t.title'))
|
|
||||||
->from($db->quoteName('#__tags', 't'))
|
|
||||||
->join('INNER', $db->quoteName('#__contentitem_tag_map', 'm')
|
|
||||||
. ' ON ' . $db->quoteName('m.tag_id') . ' = ' . $db->quoteName('t.id'))
|
|
||||||
->where($db->quoteName('m.type_alias') . ' = ' . $db->quote('com_content.article'))
|
|
||||||
->where($db->quoteName('m.content_item_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('t.published') . ' = 1');
|
|
||||||
$db->setQuery($query);
|
|
||||||
$tagNames = $db->loadColumn() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tagsComma = implode(', ', $tagNames);
|
|
||||||
$hashtags = implode(' ', array_map(function ($tag) {
|
|
||||||
return '#' . preg_replace('/\s+/', '', $tag);
|
|
||||||
}, $tagNames));
|
|
||||||
|
|
||||||
$replacements = [
|
|
||||||
'{title}' => $article->title ?? '',
|
|
||||||
'{introtext}' => strip_tags(mb_substr($article->introtext ?? '', 0, 280)),
|
|
||||||
'{fulltext}' => strip_tags(mb_substr($article->fulltext ?? '', 0, 500)),
|
|
||||||
'{url}' => $url,
|
|
||||||
'{image}' => $introImage,
|
|
||||||
'{category}' => $categoryName,
|
|
||||||
'{author}' => $authorName,
|
|
||||||
'{date}' => Factory::getDate($article->publish_up ?? 'now')->format('Y-m-d'),
|
|
||||||
'{tags}' => $tagsComma,
|
|
||||||
'{hashtags}' => $hashtags,
|
|
||||||
];
|
|
||||||
|
|
||||||
return str_replace(array_keys($replacements), array_values($replacements), $template);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a JSON response and close the application.
|
|
||||||
*
|
|
||||||
* @param array $data Response data
|
|
||||||
* @param int $httpCode HTTP status code
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function sendJsonResponse(array $data, int $httpCode): void
|
|
||||||
{
|
|
||||||
$app = $this->app;
|
|
||||||
|
|
||||||
$app->setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
||||||
$app->setHeader('Status', (string) $httpCode);
|
|
||||||
|
|
||||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
||||||
|
|
||||||
$app->close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\Controller\BaseController;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\OAuthHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OAuth controller for handling browser-based authorization flows.
|
|
||||||
*
|
|
||||||
* Endpoints:
|
|
||||||
* task=oauth.authorize — Initiate OAuth flow (redirect to platform)
|
|
||||||
* task=oauth.callback — Handle platform redirect with auth code
|
|
||||||
*/
|
|
||||||
class OauthController extends BaseController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Initiate OAuth authorization for a service.
|
|
||||||
*
|
|
||||||
* Expects: service_id (int) in request
|
|
||||||
*/
|
|
||||||
public function authorize(): void
|
|
||||||
{
|
|
||||||
$serviceId = $this->input->getInt('service_id', 0);
|
|
||||||
|
|
||||||
if (!$serviceId) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_OAUTH_NO_SERVICE'),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = \Joomla\CMS\Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $serviceId);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$service = $db->loadObject();
|
|
||||||
|
|
||||||
if (!$service) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_OAUTH_SERVICE_NOT_FOUND'),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get client ID from plugin params
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
$pluginParams = PluginHelper::getPlugin('mokojoomcross', $service->service_type);
|
|
||||||
$params = json_decode($pluginParams->params ?? '{}', true) ?: [];
|
|
||||||
|
|
||||||
$clientId = $params['client_id'] ?? '';
|
|
||||||
|
|
||||||
if (empty($clientId)) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_OAUTH_NO_CLIENT_ID', ucfirst($service->service_type)),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate CSRF nonce and store in session
|
|
||||||
$nonce = bin2hex(random_bytes(16));
|
|
||||||
Factory::getApplication()->getSession()->set('mokojoomcross.oauth_nonce', $nonce);
|
|
||||||
|
|
||||||
$url = OAuthHelper::getAuthorizeUrl($service->service_type, $serviceId, $clientId, $nonce);
|
|
||||||
|
|
||||||
if (!$url) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_OAUTH_NOT_SUPPORTED', ucfirst($service->service_type)),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->app->redirect($url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle OAuth callback from platform.
|
|
||||||
*
|
|
||||||
* Expects: code (string), state (base64 JSON with service_id)
|
|
||||||
*/
|
|
||||||
public function callback(): void
|
|
||||||
{
|
|
||||||
$code = $this->input->getString('code', '');
|
|
||||||
$state = $this->input->getString('state', '');
|
|
||||||
$error = $this->input->getString('error', '');
|
|
||||||
|
|
||||||
if ($error) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_OAUTH_PLATFORM_ERROR', $error),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($code) || empty($state)) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_OAUTH_INVALID_CALLBACK'),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stateData = json_decode(base64_decode($state), true);
|
|
||||||
$serviceId = (int) ($stateData['service_id'] ?? 0);
|
|
||||||
$serviceType = $stateData['type'] ?? '';
|
|
||||||
$stateNonce = $stateData['nonce'] ?? '';
|
|
||||||
|
|
||||||
if (!$serviceId || !$serviceType) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_OAUTH_INVALID_STATE'),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CSRF nonce validation — compare state nonce against session
|
|
||||||
$session = Factory::getApplication()->getSession();
|
|
||||||
$sessionNonce = $session->get('mokojoomcross.oauth_nonce', '');
|
|
||||||
$session->clear('mokojoomcross.oauth_nonce');
|
|
||||||
|
|
||||||
if (empty($stateNonce) || !hash_equals($sessionNonce, $stateNonce)) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=services', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_OAUTH_INVALID_STATE'),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get client credentials from plugin params
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
$pluginParams = PluginHelper::getPlugin('mokojoomcross', $serviceType);
|
|
||||||
$params = json_decode($pluginParams->params ?? '{}', true) ?: [];
|
|
||||||
|
|
||||||
$clientId = $params['client_id'] ?? '';
|
|
||||||
$clientSecret = $params['client_secret'] ?? '';
|
|
||||||
|
|
||||||
$tokenData = OAuthHelper::exchangeCode($serviceType, $code, $clientId, $clientSecret);
|
|
||||||
|
|
||||||
if (!empty($tokenData['error'])) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&task=service.edit&id=' . $serviceId, false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_OAUTH_TOKEN_ERROR', $tokenData['error']),
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OAuthHelper::storeToken($serviceId, $tokenData);
|
|
||||||
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&task=service.edit&id=' . $serviceId, false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_OAUTH_SUCCESS', ucfirst($serviceType)),
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,10 +13,7 @@ namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\Controller\AdminController;
|
use Joomla\CMS\MVC\Controller\AdminController;
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
class PostsController extends AdminController
|
class PostsController extends AdminController
|
||||||
{
|
{
|
||||||
@@ -24,214 +21,4 @@ class PostsController extends AdminController
|
|||||||
{
|
{
|
||||||
return parent::getModel($name, $prefix, $config);
|
return parent::getModel($name, $prefix, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Schedule selected posts for a future date/time.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function schedule(): void
|
|
||||||
{
|
|
||||||
$this->checkToken();
|
|
||||||
|
|
||||||
$ids = $this->input->get('cid', [], 'array');
|
|
||||||
$scheduledAt = $this->input->getString('scheduled_at', '');
|
|
||||||
|
|
||||||
if (empty($ids)) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_POSTS_NO_ITEM_SELECTED'),
|
|
||||||
'warning'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($scheduledAt)) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_SCHEDULE_NO_DATE'),
|
|
||||||
'warning'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('scheduled_at') . ' = ' . $db->quote($scheduledAt))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('queued'))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote($now))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $id);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_POSTS_N_SCHEDULED', count($ids)),
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retry selected failed/permanently_failed posts.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function retrySelected(): void
|
|
||||||
{
|
|
||||||
$this->checkToken();
|
|
||||||
|
|
||||||
$ids = $this->input->get('cid', [], 'array');
|
|
||||||
|
|
||||||
if (empty($ids)) {
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_POSTS_NO_ITEM_SELECTED'),
|
|
||||||
'warning'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = \Joomla\Component\MokoJoomCross\Administrator\Helper\QueueProcessor::retryPosts($ids);
|
|
||||||
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::sprintf('COM_MOKOJOOMCROSS_POSTS_N_RETRIED', $count),
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-queue all failed posts by resetting their status to queued and retry count to 0.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function retryFailed(): void
|
|
||||||
{
|
|
||||||
$this->checkToken();
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('queued'))
|
|
||||||
->set($db->quoteName('retry_count') . ' = 0')
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(''))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('status') . ' = ' . $db->quote('failed'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
$count = $db->getAffectedRows();
|
|
||||||
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::plural('COM_MOKOJOOMCROSS_POSTS_N_RETRIED', $count),
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Export posts as CSV download.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function exportCsv(): void
|
|
||||||
{
|
|
||||||
$app = $this->app;
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
$db->quoteName('c.title', 'article_title'),
|
|
||||||
'CONCAT(' . $db->quoteName('s.title') . ', ' . $db->quote(' (') . ', '
|
|
||||||
. $db->quoteName('s.service_type') . ', ' . $db->quote(')') . ') AS service',
|
|
||||||
$db->quoteName('a.status'),
|
|
||||||
$db->quoteName('a.message'),
|
|
||||||
$db->quoteName('a.posted_at'),
|
|
||||||
$db->quoteName('a.error_message'),
|
|
||||||
$db->quoteName('a.platform_post_id'),
|
|
||||||
$db->quoteName('a.created'),
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'a'))
|
|
||||||
->join('LEFT', $db->quoteName('#__content', 'c')
|
|
||||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.article_id'))
|
|
||||||
->join('LEFT', $db->quoteName('#__mokojoomcross_services', 's')
|
|
||||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('a.service_id'))
|
|
||||||
->order($db->quoteName('a.created') . ' DESC');
|
|
||||||
|
|
||||||
// Apply current filters
|
|
||||||
$status = $app->input->get('filter_status', '', 'string');
|
|
||||||
|
|
||||||
if (!empty($status)) {
|
|
||||||
$query->where($db->quoteName('a.status') . ' = ' . $db->quote($status));
|
|
||||||
}
|
|
||||||
|
|
||||||
$serviceId = $app->input->getInt('filter_service_id', 0);
|
|
||||||
|
|
||||||
if (!empty($serviceId)) {
|
|
||||||
$query->where($db->quoteName('a.service_id') . ' = ' . (int) $serviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$search = $app->input->get('filter_search', '', 'string');
|
|
||||||
|
|
||||||
if (!empty($search)) {
|
|
||||||
$search = '%' . $db->escape(trim($search), true) . '%';
|
|
||||||
$query->where('(' . $db->quoteName('c.title') . ' LIKE ' . $db->quote($search)
|
|
||||||
. ' OR ' . $db->quoteName('a.message') . ' LIKE ' . $db->quote($search) . ')');
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$rows = $db->loadAssocList() ?: [];
|
|
||||||
|
|
||||||
$filename = 'mokojoomcross-posts-' . Factory::getDate()->format('Y-m-d') . '.csv';
|
|
||||||
|
|
||||||
$app->setHeader('Content-Type', 'text/csv; charset=utf-8');
|
|
||||||
$app->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
|
||||||
$app->sendHeaders();
|
|
||||||
|
|
||||||
$fp = fopen('php://output', 'w');
|
|
||||||
fputcsv($fp, ['Article', 'Service', 'Status', 'Message', 'Posted At', 'Error', 'Platform Post ID', 'Created']);
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
fputcsv($fp, $row);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$app->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purge (delete) all posts with status 'posted'.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function purgePosted(): void
|
|
||||||
{
|
|
||||||
$this->checkToken();
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->delete($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('status') . ' = ' . $db->quote('posted'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
$count = $db->getAffectedRows();
|
|
||||||
|
|
||||||
$this->setRedirect(
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=posts', false),
|
|
||||||
Text::plural('COM_MOKOJOOMCROSS_POSTS_N_PURGED', $count),
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,81 +13,8 @@ namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\Controller\FormController;
|
use Joomla\CMS\MVC\Controller\FormController;
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\CMS\Response\JsonResponse;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Service\MokoJoomCrossServiceInterface;
|
|
||||||
|
|
||||||
class ServiceController extends FormController
|
class ServiceController extends FormController
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Test connection to a service by validating its credentials.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testConnection(): void
|
|
||||||
{
|
|
||||||
$app = $this->app;
|
|
||||||
$id = (int) $this->input->getInt('id', 0);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ($id <= 0) {
|
|
||||||
throw new \RuntimeException(Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_NO_SERVICE'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the service record
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $id);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$service = $db->loadObject();
|
|
||||||
|
|
||||||
if (!$service) {
|
|
||||||
throw new \RuntimeException(Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_NOT_FOUND'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get service plugins via dispatcher
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
|
|
||||||
$servicePlugins = [];
|
|
||||||
$app->getDispatcher()->dispatch(
|
|
||||||
'onMokoJoomCrossGetServices',
|
|
||||||
new \Joomla\Event\Event('onMokoJoomCrossGetServices', [&$servicePlugins])
|
|
||||||
);
|
|
||||||
|
|
||||||
// Find the matching plugin
|
|
||||||
$plugin = null;
|
|
||||||
|
|
||||||
foreach ($servicePlugins as $sp) {
|
|
||||||
if ($sp instanceof MokoJoomCrossServiceInterface && $sp->getServiceType() === $service->service_type) {
|
|
||||||
$plugin = $sp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$plugin) {
|
|
||||||
throw new \RuntimeException(Text::sprintf('COM_MOKOJOOMCROSS_TEST_CONNECTION_NO_PLUGIN', $service->service_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode credentials and validate
|
|
||||||
$credentials = json_decode($service->credentials ?: '{}', true) ?: [];
|
|
||||||
$result = $plugin->validateCredentials($credentials);
|
|
||||||
|
|
||||||
$app->mimeType = 'application/json';
|
|
||||||
$app->setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
||||||
|
|
||||||
echo new JsonResponse($result);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$app->mimeType = 'application/json';
|
|
||||||
$app->setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
||||||
|
|
||||||
echo new JsonResponse($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
$app->close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\Controller\FormController;
|
|
||||||
|
|
||||||
class TemplateController extends FormController
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Controller;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\Controller\AdminController;
|
|
||||||
|
|
||||||
class TemplatesController extends AdminController
|
|
||||||
{
|
|
||||||
public function getModel($name = 'Template', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
|
||||||
{
|
|
||||||
return parent::getModel($name, $prefix, $config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,451 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Helper;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Component\ComponentHelper;
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\CMS\Uri\Uri;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Service\MokoJoomCrossServiceInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static dispatcher for cross-posting content from any source plugin.
|
|
||||||
*
|
|
||||||
* Centralises the dispatch logic that was previously only in the system plugin,
|
|
||||||
* so content-type source plugins (articles, calendar events, gallery items) can
|
|
||||||
* trigger cross-posts without coupling to plg_system_mokojoomcross.
|
|
||||||
*/
|
|
||||||
class CrossPostDispatcher
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Dispatch an article-like payload to all enabled cross-post services.
|
|
||||||
*
|
|
||||||
* @param object $article Article or article-like object
|
|
||||||
* @param string $articleUrl Canonical URL for the content item
|
|
||||||
* @param string|null $contentType Content type context (e.g. 'com_content.article')
|
|
||||||
*/
|
|
||||||
public static function dispatch(object $article, string $articleUrl = '', ?string $contentType = null): void
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
// Load all enabled services
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('published') . ' = 1')
|
|
||||||
->order($db->quoteName('ordering') . ' ASC');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$services = $db->loadObjectList();
|
|
||||||
|
|
||||||
if (empty($services)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import service plugins so they register with the dispatcher
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
|
|
||||||
// Collect registered service plugin instances.
|
|
||||||
// In Joomla 5+ with SubscriberInterface, plugins receive the Event object
|
|
||||||
// as their first argument. When they do $services[] = $this, they append to
|
|
||||||
// the Event via ArrayAccess at numeric indices starting at 1.
|
|
||||||
$servicePlugins = [];
|
|
||||||
$event = new \Joomla\Event\Event('onMokoJoomCrossGetServices', [$servicePlugins]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Factory::getApplication()->getDispatcher()->dispatch('onMokoJoomCrossGetServices', $event);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Dispatcher may not be available in all contexts
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read plugins back from the Event's ArrayAccess indices
|
|
||||||
$idx = 1;
|
|
||||||
|
|
||||||
while (isset($event[$idx])) {
|
|
||||||
$servicePlugins[] = $event[$idx];
|
|
||||||
$idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Index by service type for lookup
|
|
||||||
$pluginMap = [];
|
|
||||||
|
|
||||||
foreach ($servicePlugins as $plugin) {
|
|
||||||
if ($plugin instanceof MokoJoomCrossServiceInterface) {
|
|
||||||
$pluginMap[$plugin->getServiceType()] = $plugin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$componentParams = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
|
|
||||||
// Per-article selective cross-posting (#19)
|
|
||||||
$attribs = json_decode($article->attribs ?? '{}', true) ?: [];
|
|
||||||
$selectedServiceIds = $attribs['mokojoomcross_services'] ?? null;
|
|
||||||
$skipCrossPost = !empty($attribs['mokojoomcross_skip']);
|
|
||||||
|
|
||||||
if ($skipCrossPost) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If specific services selected, convert to array of ints for filtering
|
|
||||||
if (is_array($selectedServiceIds) && !empty($selectedServiceIds)) {
|
|
||||||
$selectedServiceIds = array_map('intval', $selectedServiceIds);
|
|
||||||
} else {
|
|
||||||
$selectedServiceIds = null; // null = post to all
|
|
||||||
}
|
|
||||||
|
|
||||||
// Category routing rules — whitelist services by category
|
|
||||||
$categoryServiceIds = null;
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('service_id')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_category_rules'))
|
|
||||||
->where($db->quoteName('category_id') . ' = ' . (int) $article->catid)
|
|
||||||
->where($db->quoteName('published') . ' = 1');
|
|
||||||
$db->setQuery($query);
|
|
||||||
$ruleIds = $db->loadColumn();
|
|
||||||
|
|
||||||
if (!empty($ruleIds)) {
|
|
||||||
$categoryServiceIds = array_map('intval', $ruleIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine service type filter from content type property
|
|
||||||
$serviceTypeFilter = $article->_content_type ?? null;
|
|
||||||
|
|
||||||
foreach ($services as $service) {
|
|
||||||
// Category routing filter — if rules exist, only post to whitelisted services
|
|
||||||
if ($categoryServiceIds !== null && !in_array((int) $service->id, $categoryServiceIds, true)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Service type filter for non-article content types
|
|
||||||
if ($serviceTypeFilter !== null && $service->service_type !== $serviceTypeFilter) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Per-article filter
|
|
||||||
if ($selectedServiceIds !== null && !in_array((int) $service->id, $selectedServiceIds, true)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Duplicate guard
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('article_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . (int) $service->id)
|
|
||||||
->where($db->quoteName('status') . ' IN (' . $db->quote('queued') . ',' . $db->quote('posted') . ',' . $db->quote('posting') . ')');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
if ((int) $db->loadResult() > 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = self::renderTemplate($article, $service);
|
|
||||||
|
|
||||||
// Extract intro image for media attachment
|
|
||||||
$media = [];
|
|
||||||
$images = json_decode($article->images ?? '{}');
|
|
||||||
|
|
||||||
if (!empty($images->image_intro)) {
|
|
||||||
$media[] = Uri::root() . ltrim($images->image_intro, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create queue entry
|
|
||||||
$post = (object) [
|
|
||||||
'article_id' => (int) $article->id,
|
|
||||||
'service_id' => (int) $service->id,
|
|
||||||
'status' => 'queued',
|
|
||||||
'message' => $message,
|
|
||||||
'platform_post_id' => '',
|
|
||||||
'platform_response' => '',
|
|
||||||
'error_message' => '',
|
|
||||||
'retry_count' => 0,
|
|
||||||
'created' => Factory::getDate()->toSql(),
|
|
||||||
'modified' => Factory::getDate()->toSql(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$db->insertObject('#__mokojoomcross_posts', $post);
|
|
||||||
$postId = $db->insertid();
|
|
||||||
|
|
||||||
// Resolve article URL
|
|
||||||
$url = $article->_article_url ?? $articleUrl;
|
|
||||||
|
|
||||||
if (empty($url)) {
|
|
||||||
$url = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id
|
|
||||||
. (!empty($article->catid) ? '&catid=' . $article->catid : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt immediate dispatch if service plugin is available
|
|
||||||
$plugin = $pluginMap[$service->service_type] ?? null;
|
|
||||||
|
|
||||||
if ($plugin) {
|
|
||||||
self::executePost($db, $postId, $plugin, $message, $service, $media, $url);
|
|
||||||
} else {
|
|
||||||
self::log($db, $postId, $service->id, 'warning',
|
|
||||||
sprintf('No service plugin found for type "%s" — post remains queued', $service->service_type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a cross-post via the service plugin.
|
|
||||||
*/
|
|
||||||
private static function executePost($db, int $postId, MokoJoomCrossServiceInterface $plugin, string $message, object $service, array $media = [], string $articleUrl = ''): void
|
|
||||||
{
|
|
||||||
// Mark as posting
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('posting'))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $postId)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
$credentials = json_decode($service->credentials ?: '{}', true) ?: [];
|
|
||||||
$params = json_decode($service->params ?: '{}', true) ?: [];
|
|
||||||
|
|
||||||
if (!empty($articleUrl)) {
|
|
||||||
$params['_article_url'] = $articleUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lifecycle event: before post
|
|
||||||
$cancel = false;
|
|
||||||
$dispatcher = Factory::getApplication()->getDispatcher();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$beforeEvent = new \Joomla\Event\Event('onMokoJoomCrossBeforePost', [$postId, &$message, $service->service_type, &$cancel]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossBeforePost', $beforeEvent);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Dispatcher may not be available
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cancel) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('cancelled'))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $postId)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, $postId, $service->id, 'info',
|
|
||||||
sprintf('Post to %s cancelled by onMokoJoomCrossBeforePost event', $service->service_type));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$result = $plugin->publish($message, $media, $credentials, $params);
|
|
||||||
|
|
||||||
if (!empty($result['success'])) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('posted'))
|
|
||||||
->set($db->quoteName('platform_post_id') . ' = ' . $db->quote($result['platform_post_id'] ?? ''))
|
|
||||||
->set($db->quoteName('platform_response') . ' = ' . $db->quote(json_encode($result['response'] ?? [])))
|
|
||||||
->set($db->quoteName('posted_at') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $postId)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, $postId, $service->id, 'info',
|
|
||||||
sprintf('Posted to %s (platform ID: %s)', $service->service_type, $result['platform_post_id'] ?? 'n/a'));
|
|
||||||
|
|
||||||
try {
|
|
||||||
$afterEvent = new \Joomla\Event\Event('onMokoJoomCrossAfterPost', [$postId, $service->service_type, $result]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossAfterPost', $afterEvent);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Non-critical
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$errorMsg = $result['response']['error'] ?? json_encode($result['response'] ?? []);
|
|
||||||
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('failed'))
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(mb_substr($errorMsg, 0, 1000)))
|
|
||||||
->set($db->quoteName('platform_response') . ' = ' . $db->quote(json_encode($result['response'] ?? [])))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $postId)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, $postId, $service->id, 'error',
|
|
||||||
sprintf('Failed to post to %s: %s', $service->service_type, $errorMsg));
|
|
||||||
|
|
||||||
try {
|
|
||||||
$failedEvent = new \Joomla\Event\Event('onMokoJoomCrossPostFailed', [$postId, $service->service_type, $errorMsg]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossPostFailed', $failedEvent);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Non-critical
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('failed'))
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(mb_substr($e->getMessage(), 0, 1000)))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $postId)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, $postId, $service->id, 'error',
|
|
||||||
sprintf('Exception posting to %s: %s', $service->service_type, $e->getMessage()));
|
|
||||||
|
|
||||||
try {
|
|
||||||
$failedEvent = new \Joomla\Event\Event('onMokoJoomCrossPostFailed', [$postId, $service->service_type, $e->getMessage()]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossPostFailed', $failedEvent);
|
|
||||||
} catch (\Throwable $ex) {
|
|
||||||
// Non-critical
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the message template for a service.
|
|
||||||
*/
|
|
||||||
private static function renderTemplate(object $article, object $service): string
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
// Try service-specific template first, fall back to default
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('template_body'))
|
|
||||||
->from($db->quoteName('#__mokojoomcross_templates'))
|
|
||||||
->where($db->quoteName('published') . ' = 1')
|
|
||||||
->where('(' . $db->quoteName('service_type') . ' = ' . $db->quote($service->service_type)
|
|
||||||
. ' OR ' . $db->quoteName('service_type') . ' = ' . $db->quote('default') . ')')
|
|
||||||
->order('CASE WHEN ' . $db->quoteName('service_type') . ' = '
|
|
||||||
. $db->quote($service->service_type) . ' THEN 0 ELSE 1 END')
|
|
||||||
->setLimit(1);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$template = $db->loadResult() ?: "{title}\n\n{url}";
|
|
||||||
|
|
||||||
// Build SEF article URL
|
|
||||||
$url = $article->_article_url
|
|
||||||
?? (Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id
|
|
||||||
. (!empty($article->catid) ? '&catid=' . $article->catid : ''));
|
|
||||||
|
|
||||||
// Resolve category name
|
|
||||||
$categoryName = '';
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('title'))
|
|
||||||
->from($db->quoteName('#__categories'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->catid);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$categoryName = $db->loadResult() ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve author name
|
|
||||||
$authorName = '';
|
|
||||||
|
|
||||||
if (!empty($article->created_by)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('name'))
|
|
||||||
->from($db->quoteName('#__users'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->created_by);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$authorName = $db->loadResult() ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract intro image
|
|
||||||
$introImage = '';
|
|
||||||
$images = json_decode($article->images ?? '{}');
|
|
||||||
|
|
||||||
if (!empty($images->image_intro)) {
|
|
||||||
$introImage = Uri::root() . ltrim($images->image_intro, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve article tags
|
|
||||||
$tagNames = [];
|
|
||||||
|
|
||||||
if (!empty($article->id)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('t.title'))
|
|
||||||
->from($db->quoteName('#__tags', 't'))
|
|
||||||
->join('INNER', $db->quoteName('#__contentitem_tag_map', 'm')
|
|
||||||
. ' ON ' . $db->quoteName('m.tag_id') . ' = ' . $db->quoteName('t.id'))
|
|
||||||
->where($db->quoteName('m.type_alias') . ' = ' . $db->quote('com_content.article'))
|
|
||||||
->where($db->quoteName('m.content_item_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('t.published') . ' = 1');
|
|
||||||
$db->setQuery($query);
|
|
||||||
$tagNames = $db->loadColumn() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tagsComma = implode(', ', $tagNames);
|
|
||||||
$hashtags = implode(' ', array_map(function ($tag) {
|
|
||||||
return '#' . preg_replace('/\s+/', '', $tag);
|
|
||||||
}, $tagNames));
|
|
||||||
|
|
||||||
// Replace placeholders
|
|
||||||
$replacements = [
|
|
||||||
'{title}' => $article->title ?? '',
|
|
||||||
'{introtext}' => strip_tags(mb_substr($article->introtext ?? '', 0, 280)),
|
|
||||||
'{fulltext}' => strip_tags(mb_substr($article->fulltext ?? '', 0, 500)),
|
|
||||||
'{url}' => $url,
|
|
||||||
'{image}' => $introImage,
|
|
||||||
'{category}' => $categoryName,
|
|
||||||
'{author}' => $authorName,
|
|
||||||
'{date}' => Factory::getDate($article->publish_up ?? 'now')->format('Y-m-d'),
|
|
||||||
'{tags}' => $tagsComma,
|
|
||||||
'{hashtags}' => $hashtags,
|
|
||||||
];
|
|
||||||
|
|
||||||
$message = str_replace(array_keys($replacements), array_values($replacements), $template);
|
|
||||||
|
|
||||||
// Resolve custom field placeholders: {field:field_name}
|
|
||||||
$message = preg_replace_callback('/\{field:([a-zA-Z0-9_-]+)\}/', function ($matches) use ($db, $article) {
|
|
||||||
$fieldName = $matches[1];
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('fv.value')
|
|
||||||
->from($db->quoteName('#__fields_values', 'fv'))
|
|
||||||
->join('INNER', $db->quoteName('#__fields', 'f') . ' ON f.id = fv.field_id')
|
|
||||||
->where('f.name = ' . $db->quote($fieldName))
|
|
||||||
->where('fv.item_id = ' . (int) $article->id);
|
|
||||||
$db->setQuery($query);
|
|
||||||
return $db->loadResult() ?: '';
|
|
||||||
}, $message);
|
|
||||||
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write an entry to the activity log.
|
|
||||||
*/
|
|
||||||
private static function log($db, ?int $postId, ?int $serviceId, string $level, string $message): void
|
|
||||||
{
|
|
||||||
$log = (object) [
|
|
||||||
'post_id' => $postId,
|
|
||||||
'service_id' => $serviceId,
|
|
||||||
'level' => $level,
|
|
||||||
'message' => mb_substr($message, 0, 2000),
|
|
||||||
'context' => '{}',
|
|
||||||
'created' => Factory::getDate()->toSql(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$db->insertObject('#__mokojoomcross_logs', $log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,42 +16,28 @@ defined('_JEXEC') or die;
|
|||||||
use Joomla\CMS\Factory;
|
use Joomla\CMS\Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migration helper for importing settings from Perfect Publisher Pro (com_autotweet).
|
* Migration helper for importing settings from Perfect Publisher Pro.
|
||||||
*
|
*
|
||||||
* PP Pro stores channels in #__autotweet_channels with a channeltype_id FK
|
* Reads Perfect Publisher Pro's component params and plugin configurations
|
||||||
* to #__autotweet_channeltypes. Each channel has a JSON params column
|
* and maps them to MokoJoomCross service records.
|
||||||
* containing OAuth tokens, API keys, webhook URLs, etc.
|
|
||||||
*
|
|
||||||
* This helper reads those channels and creates MokoJoomCross service records.
|
|
||||||
*/
|
*/
|
||||||
class MigrationHelper
|
class MigrationHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Channel type name → MokoJoomCross service type mapping.
|
* Service type mapping from Perfect Publisher Pro to MokoJoomCross.
|
||||||
* PP Pro channeltype names vary; we match common patterns.
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private const CHANNEL_MAP = [
|
private const SERVICE_MAP = [
|
||||||
'facebook' => 'facebook',
|
'facebook' => 'facebook',
|
||||||
'fb' => 'facebook',
|
'twitter' => 'twitter',
|
||||||
'twitter' => 'twitter',
|
'linkedin' => 'linkedin',
|
||||||
'tw' => 'twitter',
|
'telegram' => 'telegram',
|
||||||
'linkedin' => 'linkedin',
|
|
||||||
'li' => 'linkedin',
|
|
||||||
'telegram' => 'telegram',
|
|
||||||
'tg' => 'telegram',
|
|
||||||
'discord' => 'discord',
|
|
||||||
'slack' => 'slack',
|
|
||||||
'mastodon' => 'mastodon',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the full migration from Perfect Publisher Pro.
|
* Run the full migration from Perfect Publisher Pro.
|
||||||
*
|
*
|
||||||
* Strategy:
|
|
||||||
* 1. Try reading #__autotweet_channels (PP Pro's channel table)
|
|
||||||
* 2. Fall back to reading component params if table doesn't exist
|
|
||||||
* 3. Create disabled MokoJoomCross service records
|
|
||||||
*
|
|
||||||
* @return array ['migrated' => int, 'skipped' => int, 'errors' => string[]]
|
* @return array ['migrated' => int, 'skipped' => int, 'errors' => string[]]
|
||||||
*/
|
*/
|
||||||
public static function migrate(): array
|
public static function migrate(): array
|
||||||
@@ -59,231 +45,18 @@ class MigrationHelper
|
|||||||
$db = Factory::getDbo();
|
$db = Factory::getDbo();
|
||||||
$result = ['migrated' => 0, 'skipped' => 0, 'errors' => []];
|
$result = ['migrated' => 0, 'skipped' => 0, 'errors' => []];
|
||||||
|
|
||||||
// Check if PP Pro is installed
|
// Read Perfect Publisher Pro component params
|
||||||
if (!self::isPPProInstalled($db)) {
|
|
||||||
$result['errors'][] = 'Perfect Publisher Pro (com_autotweet) is not installed.';
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try channel-based migration first (PP Pro stores configs in #__autotweet_channels)
|
|
||||||
if (self::hasChannelTable($db)) {
|
|
||||||
$result = self::migrateFromChannels($db, $result);
|
|
||||||
} else {
|
|
||||||
// Fall back to component params extraction
|
|
||||||
$result = self::migrateFromParams($db, $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear migration flag from MokoJoomCross params
|
|
||||||
self::clearMigrationFlag($db);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if PP Pro is installed.
|
|
||||||
*/
|
|
||||||
private static function isPPProInstalled($db): bool
|
|
||||||
{
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__extensions'))
|
|
||||||
->where('(' . $db->quoteName('element') . ' = ' . $db->quote('com_autotweet')
|
|
||||||
. ' OR ' . $db->quoteName('element') . ' LIKE ' . $db->quote('%perfectpublisher%') . ')')
|
|
||||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
return (int) $db->loadResult() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the autotweet_channels table exists.
|
|
||||||
*/
|
|
||||||
private static function hasChannelTable($db): bool
|
|
||||||
{
|
|
||||||
$prefix = $db->getPrefix();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$db->setQuery('SHOW TABLES LIKE ' . $db->quote($prefix . 'autotweet_channels'));
|
|
||||||
|
|
||||||
return !empty($db->loadResult());
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Migrate from #__autotweet_channels table (primary method).
|
|
||||||
*/
|
|
||||||
private static function migrateFromChannels($db, array $result): array
|
|
||||||
{
|
|
||||||
// Load channels with their type names
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('c.id, c.name, c.published, c.params')
|
|
||||||
->select($db->quoteName('ct.name', 'type_name'))
|
|
||||||
->from($db->quoteName('#__autotweet_channels', 'c'))
|
|
||||||
->join('LEFT', $db->quoteName('#__autotweet_channeltypes', 'ct')
|
|
||||||
. ' ON ' . $db->quoteName('ct.id') . ' = ' . $db->quoteName('c.channeltype_id'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$channels = $db->loadObjectList();
|
|
||||||
|
|
||||||
if (empty($channels)) {
|
|
||||||
$result['errors'][] = 'No channels found in Perfect Publisher Pro.';
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($channels as $channel) {
|
|
||||||
$typeName = strtolower(trim($channel->type_name ?? ''));
|
|
||||||
|
|
||||||
// Match to MokoJoomCross service type
|
|
||||||
$mjcType = null;
|
|
||||||
|
|
||||||
foreach (self::CHANNEL_MAP as $pattern => $serviceType) {
|
|
||||||
if (str_contains($typeName, $pattern)) {
|
|
||||||
$mjcType = $serviceType;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$mjcType) {
|
|
||||||
$result['skipped']++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for duplicate (same type + migrated alias)
|
|
||||||
$alias = $mjcType . '-pp-' . $channel->id;
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('alias') . ' = ' . $db->quote($alias));
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
if ((int) $db->loadResult() > 0) {
|
|
||||||
$result['skipped']++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse channel params to extract credentials
|
|
||||||
$channelParams = json_decode($channel->params ?: '{}', true) ?: [];
|
|
||||||
$credentials = self::mapChannelCredentials($mjcType, $channelParams);
|
|
||||||
|
|
||||||
if (empty($credentials)) {
|
|
||||||
$result['skipped']++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create MokoJoomCross service record
|
|
||||||
$service = (object) [
|
|
||||||
'title' => $channel->name ?: ucfirst($mjcType) . ' (PP Pro #' . $channel->id . ')',
|
|
||||||
'alias' => $alias,
|
|
||||||
'service_type' => $mjcType,
|
|
||||||
'credentials' => json_encode($credentials),
|
|
||||||
'params' => '{}',
|
|
||||||
'published' => 0, // Disabled — user must verify before enabling
|
|
||||||
'ordering' => 0,
|
|
||||||
'created' => Factory::getDate()->toSql(),
|
|
||||||
'modified' => Factory::getDate()->toSql(),
|
|
||||||
'created_by' => Factory::getApplication()->getIdentity()->id ?? 0,
|
|
||||||
];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$db->insertObject('#__mokojoomcross_services', $service);
|
|
||||||
$result['migrated']++;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$result['errors'][] = sprintf('Failed to create %s service: %s', $mjcType, $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map PP Pro channel params to MokoJoomCross credential format.
|
|
||||||
*
|
|
||||||
* PP Pro stores various keys in channel params depending on the type.
|
|
||||||
* We normalize them to MokoJoomCross's expected credential structure.
|
|
||||||
*/
|
|
||||||
private static function mapChannelCredentials(string $serviceType, array $channelParams): array
|
|
||||||
{
|
|
||||||
$creds = ['mode' => 'custom'];
|
|
||||||
|
|
||||||
// Common OAuth fields PP Pro uses
|
|
||||||
$oauthFields = ['access_token', 'access_secret', 'client_id', 'client_secret',
|
|
||||||
'api_key', 'api_secret', 'app_id', 'app_secret', 'token'];
|
|
||||||
|
|
||||||
switch ($serviceType) {
|
|
||||||
case 'facebook':
|
|
||||||
$creds['page_access_token'] = $channelParams['access_token'] ?? $channelParams['token'] ?? '';
|
|
||||||
$creds['page_id'] = $channelParams['page_id'] ?? $channelParams['pageid'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'twitter':
|
|
||||||
$creds['bearer_token'] = $channelParams['bearer_token'] ?? '';
|
|
||||||
$creds['api_key'] = $channelParams['api_key'] ?? $channelParams['consumer_key'] ?? '';
|
|
||||||
$creds['api_secret'] = $channelParams['api_secret'] ?? $channelParams['consumer_secret'] ?? '';
|
|
||||||
$creds['access_token'] = $channelParams['access_token'] ?? '';
|
|
||||||
$creds['access_token_secret'] = $channelParams['access_secret'] ?? $channelParams['access_token_secret'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'linkedin':
|
|
||||||
$creds['access_token'] = $channelParams['access_token'] ?? $channelParams['token'] ?? '';
|
|
||||||
$creds['organization_id'] = $channelParams['company_id'] ?? $channelParams['organization_id'] ?? '';
|
|
||||||
$creds['person_id'] = $channelParams['person_id'] ?? $channelParams['member_id'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'telegram':
|
|
||||||
$creds['bot_token'] = $channelParams['bot_token'] ?? $channelParams['token'] ?? $channelParams['api_key'] ?? '';
|
|
||||||
$creds['chat_id'] = $channelParams['chat_id'] ?? $channelParams['channel_id'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'discord':
|
|
||||||
$creds['webhook_url'] = $channelParams['webhook_url'] ?? $channelParams['webhook'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'slack':
|
|
||||||
$creds['webhook_url'] = $channelParams['webhook_url'] ?? $channelParams['webhook'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'mastodon':
|
|
||||||
$creds['instance_url'] = $channelParams['instance_url'] ?? $channelParams['server'] ?? '';
|
|
||||||
$creds['access_token'] = $channelParams['access_token'] ?? $channelParams['token'] ?? '';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Generic: copy all non-empty params
|
|
||||||
foreach ($channelParams as $key => $value) {
|
|
||||||
if (!empty($value) && is_string($value)) {
|
|
||||||
$creds[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove empty credential values and the mode key for check
|
|
||||||
$check = array_filter($creds, fn($v, $k) => $k !== 'mode' && !empty($v), ARRAY_FILTER_USE_BOTH);
|
|
||||||
|
|
||||||
return empty($check) ? [] : $creds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fallback: migrate from component params when channel table doesn't exist.
|
|
||||||
*/
|
|
||||||
private static function migrateFromParams($db, array $result): array
|
|
||||||
{
|
|
||||||
$query = $db->getQuery(true)
|
$query = $db->getQuery(true)
|
||||||
->select($db->quoteName('params'))
|
->select($db->quoteName('params'))
|
||||||
->from($db->quoteName('#__extensions'))
|
->from($db->quoteName('#__extensions'))
|
||||||
->where('(' . $db->quoteName('element') . ' = ' . $db->quote('com_autotweet')
|
->where($db->quoteName('element') . ' LIKE ' . $db->quote('%perfectpublisher%'))
|
||||||
. ' OR ' . $db->quoteName('element') . ' LIKE ' . $db->quote('%perfectpublisher%') . ')')
|
|
||||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
|
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
|
||||||
|
|
||||||
$db->setQuery($query);
|
$db->setQuery($query);
|
||||||
$rawParams = $db->loadResult();
|
$rawParams = $db->loadResult();
|
||||||
|
|
||||||
if (!$rawParams) {
|
if (!$rawParams) {
|
||||||
$result['errors'][] = 'No PP Pro configuration found.';
|
$result['errors'][] = 'Perfect Publisher Pro not found or has no configuration.';
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -291,44 +64,25 @@ class MigrationHelper
|
|||||||
$params = json_decode($rawParams, true);
|
$params = json_decode($rawParams, true);
|
||||||
|
|
||||||
if (!is_array($params)) {
|
if (!is_array($params)) {
|
||||||
$result['errors'][] = 'Could not parse PP Pro configuration.';
|
$result['errors'][] = 'Could not parse Perfect Publisher Pro configuration.';
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract services from component params using prefix patterns
|
// Iterate known service mappings and create MokoJoomCross service records
|
||||||
$servicePatterns = [
|
foreach (self::SERVICE_MAP as $ppKey => $mjcType) {
|
||||||
'facebook' => ['facebook_', 'fb_'],
|
$credentials = self::extractCredentials($params, $ppKey);
|
||||||
'twitter' => ['twitter_', 'tw_'],
|
|
||||||
'linkedin' => ['linkedin_', 'li_'],
|
|
||||||
'telegram' => ['telegram_', 'tg_'],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($servicePatterns as $mjcType => $prefixes) {
|
if (empty($credentials)) {
|
||||||
$credentials = ['mode' => 'custom'];
|
|
||||||
$found = false;
|
|
||||||
|
|
||||||
foreach ($params as $key => $value) {
|
|
||||||
foreach ($prefixes as $prefix) {
|
|
||||||
if (str_starts_with($key, $prefix) && !empty($value)) {
|
|
||||||
$cleanKey = substr($key, strlen($prefix));
|
|
||||||
$credentials[$cleanKey] = $value;
|
|
||||||
$found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$found) {
|
|
||||||
$result['skipped']++;
|
$result['skipped']++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicate check
|
// Check if service already exists
|
||||||
$query = $db->getQuery(true)
|
$query = $db->getQuery(true)
|
||||||
->select('COUNT(*)')
|
->select('COUNT(*)')
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
->from($db->quoteName('#__mokojoomcross_services'))
|
||||||
->where($db->quoteName('service_type') . ' = ' . $db->quote($mjcType))
|
->where($db->quoteName('service_type') . ' = ' . $db->quote($mjcType));
|
||||||
->where($db->quoteName('alias') . ' LIKE ' . $db->quote('%-migrated%'));
|
|
||||||
$db->setQuery($query);
|
$db->setQuery($query);
|
||||||
|
|
||||||
if ((int) $db->loadResult() > 0) {
|
if ((int) $db->loadResult() > 0) {
|
||||||
@@ -336,53 +90,60 @@ class MigrationHelper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert new service record
|
||||||
$service = (object) [
|
$service = (object) [
|
||||||
'title' => ucfirst($mjcType) . ' (migrated from PP Pro)',
|
'title' => ucfirst($mjcType) . ' (migrated from PP Pro)',
|
||||||
'alias' => $mjcType . '-migrated',
|
'alias' => $mjcType . '-migrated',
|
||||||
'service_type' => $mjcType,
|
'service_type' => $mjcType,
|
||||||
'credentials' => json_encode($credentials),
|
'credentials' => json_encode($credentials),
|
||||||
'params' => '{}',
|
'params' => '{}',
|
||||||
'published' => 0,
|
'published' => 0, // Disabled until user verifies
|
||||||
'ordering' => 0,
|
'ordering' => 0,
|
||||||
'created' => Factory::getDate()->toSql(),
|
'created' => Factory::getDate()->toSql(),
|
||||||
'modified' => Factory::getDate()->toSql(),
|
'modified' => Factory::getDate()->toSql(),
|
||||||
'created_by' => Factory::getApplication()->getIdentity()->id ?? 0,
|
'created_by' => Factory::getApplication()->getIdentity()->id ?? 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
$db->insertObject('#__mokojoomcross_services', $service);
|
||||||
$db->insertObject('#__mokojoomcross_services', $service);
|
$result['migrated']++;
|
||||||
$result['migrated']++;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$result['errors'][] = sprintf('Failed to create %s: %s', $mjcType, $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear migration flag
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->update($db->quoteName('#__extensions'))
|
||||||
|
->set($db->quoteName('params') . ' = ' . $db->quote('{}'))
|
||||||
|
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
||||||
|
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokojoomcross'));
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the migration flag from MokoJoomCross component params.
|
* Extract credentials for a specific service from PP Pro params.
|
||||||
|
*
|
||||||
|
* @param array $params PP Pro component params
|
||||||
|
* @param string $serviceKey Service key in PP Pro params
|
||||||
|
*
|
||||||
|
* @return array Credential key/value pairs (empty if none found)
|
||||||
*/
|
*/
|
||||||
private static function clearMigrationFlag($db): void
|
private static function extractCredentials(array $params, string $serviceKey): array
|
||||||
{
|
{
|
||||||
$query = $db->getQuery(true)
|
$credentials = [];
|
||||||
->select($db->quoteName('params'))
|
|
||||||
->from($db->quoteName('#__extensions'))
|
|
||||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
|
||||||
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokojoomcross'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
// PP Pro uses various key patterns: {service}_app_id, {service}_api_key, etc.
|
||||||
$params = json_decode($db->loadResult() ?: '{}', true) ?: [];
|
$prefixes = [$serviceKey . '_', $serviceKey . 'api_', $serviceKey . '-'];
|
||||||
|
|
||||||
unset($params['migration_available'], $params['migration_source_params']);
|
foreach ($params as $key => $value) {
|
||||||
|
foreach ($prefixes as $prefix) {
|
||||||
|
if (str_starts_with($key, $prefix) && !empty($value)) {
|
||||||
|
$cleanKey = str_replace($prefix, '', $key);
|
||||||
|
$credentials[$cleanKey] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
return $credentials;
|
||||||
->update($db->quoteName('#__extensions'))
|
|
||||||
->set($db->quoteName('params') . ' = ' . $db->quote(json_encode($params)))
|
|
||||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
|
||||||
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokojoomcross'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Helper;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Component helper — renders the admin submenu sidebar.
|
|
||||||
*/
|
|
||||||
class MokoJoomCrossHelper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Configure the submenu links.
|
|
||||||
*
|
|
||||||
* Called from each view's addToolbar() to highlight the active item.
|
|
||||||
*
|
|
||||||
* @param string $activeView The current view name
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function addSubmenu(string $activeView): void
|
|
||||||
{
|
|
||||||
\Joomla\CMS\HTML\Sidebar::addEntry(
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD'),
|
|
||||||
'index.php?option=com_mokojoomcross&view=dashboard',
|
|
||||||
$activeView === 'dashboard'
|
|
||||||
);
|
|
||||||
|
|
||||||
\Joomla\CMS\HTML\Sidebar::addEntry(
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_SUBMENU_POSTS'),
|
|
||||||
'index.php?option=com_mokojoomcross&view=posts',
|
|
||||||
$activeView === 'posts'
|
|
||||||
);
|
|
||||||
|
|
||||||
\Joomla\CMS\HTML\Sidebar::addEntry(
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_SUBMENU_SERVICES'),
|
|
||||||
'index.php?option=com_mokojoomcross&view=services',
|
|
||||||
$activeView === 'services'
|
|
||||||
);
|
|
||||||
|
|
||||||
\Joomla\CMS\HTML\Sidebar::addEntry(
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_SUBMENU_TEMPLATES'),
|
|
||||||
'index.php?option=com_mokojoomcross&view=templates',
|
|
||||||
$activeView === 'templates'
|
|
||||||
);
|
|
||||||
|
|
||||||
\Joomla\CMS\HTML\Sidebar::addEntry(
|
|
||||||
Text::_('COM_MOKOJOOMCROSS_SUBMENU_LOGS'),
|
|
||||||
'index.php?option=com_mokojoomcross&view=logs',
|
|
||||||
$activeView === 'logs'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Helper;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\CMS\Uri\Uri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OAuth helper for services requiring browser-based authorization.
|
|
||||||
*
|
|
||||||
* Handles the OAuth 2.0 authorization code flow:
|
|
||||||
* 1. Generate authorize URL → redirect user to platform
|
|
||||||
* 2. Platform redirects back with auth code
|
|
||||||
* 3. Exchange code for access token
|
|
||||||
* 4. Store token in service credentials
|
|
||||||
*
|
|
||||||
* Each platform has its own endpoints and scopes. The service plugin
|
|
||||||
* provides these via OAuthConfigInterface (if it supports OAuth).
|
|
||||||
*/
|
|
||||||
class OAuthHelper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* OAuth endpoint configs per service type.
|
|
||||||
*/
|
|
||||||
private const OAUTH_CONFIGS = [
|
|
||||||
'facebook' => [
|
|
||||||
'authorize_url' => 'https://www.facebook.com/v19.0/dialog/oauth',
|
|
||||||
'token_url' => 'https://graph.facebook.com/v19.0/oauth/access_token',
|
|
||||||
'scopes' => 'pages_manage_posts,pages_read_engagement',
|
|
||||||
],
|
|
||||||
'linkedin' => [
|
|
||||||
'authorize_url' => 'https://www.linkedin.com/oauth/v2/authorization',
|
|
||||||
'token_url' => 'https://www.linkedin.com/oauth/v2/accessToken',
|
|
||||||
'scopes' => 'w_member_social',
|
|
||||||
],
|
|
||||||
'twitter' => [
|
|
||||||
'authorize_url' => 'https://twitter.com/i/oauth2/authorize',
|
|
||||||
'token_url' => 'https://api.twitter.com/2/oauth2/token',
|
|
||||||
'scopes' => 'tweet.read tweet.write users.read',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the authorization URL for a given service.
|
|
||||||
*
|
|
||||||
* @param string $serviceType Service type (facebook, linkedin, twitter)
|
|
||||||
* @param int $serviceId Service record ID (passed through state param)
|
|
||||||
* @param string $clientId OAuth client/app ID
|
|
||||||
*
|
|
||||||
* @return string|null Authorization URL or null if not supported
|
|
||||||
*/
|
|
||||||
public static function getAuthorizeUrl(string $serviceType, int $serviceId, string $clientId, string $nonce = ''): ?string
|
|
||||||
{
|
|
||||||
$config = self::OAUTH_CONFIGS[$serviceType] ?? null;
|
|
||||||
|
|
||||||
if (!$config) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$redirectUri = self::getCallbackUrl();
|
|
||||||
$statePayload = ['service_id' => $serviceId, 'type' => $serviceType];
|
|
||||||
|
|
||||||
if (!empty($nonce)) {
|
|
||||||
$statePayload['nonce'] = $nonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
$state = base64_encode(json_encode($statePayload));
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'redirect_uri' => $redirectUri,
|
|
||||||
'response_type' => 'code',
|
|
||||||
'scope' => $config['scopes'],
|
|
||||||
'state' => $state,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Twitter uses PKCE
|
|
||||||
if ($serviceType === 'twitter') {
|
|
||||||
$verifier = bin2hex(random_bytes(32));
|
|
||||||
$challenge = rtrim(strtr(base64_encode(hash('sha256', $verifier, true)), '+/', '-_'), '=');
|
|
||||||
|
|
||||||
// Store verifier in session for token exchange
|
|
||||||
Factory::getApplication()->getSession()->set('mokojoomcross.pkce_verifier', $verifier);
|
|
||||||
|
|
||||||
$params['code_challenge'] = $challenge;
|
|
||||||
$params['code_challenge_method'] = 'S256';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $config['authorize_url'] . '?' . http_build_query($params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exchange authorization code for access token.
|
|
||||||
*
|
|
||||||
* @param string $serviceType Service type
|
|
||||||
* @param string $code Authorization code from callback
|
|
||||||
* @param string $clientId OAuth client ID
|
|
||||||
* @param string $clientSecret OAuth client secret
|
|
||||||
*
|
|
||||||
* @return array ['access_token' => '...', 'expires_in' => N, ...] or ['error' => '...']
|
|
||||||
*/
|
|
||||||
public static function exchangeCode(string $serviceType, string $code, string $clientId, string $clientSecret): array
|
|
||||||
{
|
|
||||||
$config = self::OAUTH_CONFIGS[$serviceType] ?? null;
|
|
||||||
|
|
||||||
if (!$config) {
|
|
||||||
return ['error' => 'Unsupported service type for OAuth'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$postData = [
|
|
||||||
'grant_type' => 'authorization_code',
|
|
||||||
'code' => $code,
|
|
||||||
'redirect_uri' => self::getCallbackUrl(),
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'client_secret' => $clientSecret,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Twitter PKCE
|
|
||||||
if ($serviceType === 'twitter') {
|
|
||||||
$verifier = Factory::getApplication()->getSession()->get('mokojoomcross.pkce_verifier', '');
|
|
||||||
$postData['code_verifier'] = $verifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ch = curl_init($config['token_url']);
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => http_build_query($postData),
|
|
||||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded', 'Accept: application/json'],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 30,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if ($httpCode >= 200 && $httpCode < 300 && !empty($data['access_token'])) {
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['error' => $data['error_description'] ?? $data['error'] ?? 'Token exchange failed'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store OAuth token in the service credentials.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service record ID
|
|
||||||
* @param array $tokenData Token response from platform
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function storeToken(int $serviceId, array $tokenData): bool
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('credentials'))
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $serviceId);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$credentials = json_decode($db->loadResult() ?: '{}', true) ?: [];
|
|
||||||
|
|
||||||
$credentials['access_token'] = $tokenData['access_token'];
|
|
||||||
$credentials['mode'] = 'custom';
|
|
||||||
|
|
||||||
if (!empty($tokenData['refresh_token'])) {
|
|
||||||
$credentials['refresh_token'] = $tokenData['refresh_token'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($tokenData['expires_in'])) {
|
|
||||||
$credentials['token_expires'] = time() + (int) $tokenData['expires_in'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->set($db->quoteName('credentials') . ' = ' . $db->quote(json_encode($credentials)))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $serviceId);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh an OAuth token if it has expired.
|
|
||||||
*
|
|
||||||
* Checks `token_expires` in the credentials array. If the token is expired
|
|
||||||
* and a refresh_token is available, performs the refresh grant and updates
|
|
||||||
* both the DB and the passed-in credentials array.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service record ID
|
|
||||||
* @param array &$credentials Credentials array (updated by reference on refresh)
|
|
||||||
*
|
|
||||||
* @return bool True if token was refreshed, false otherwise
|
|
||||||
*/
|
|
||||||
public static function refreshTokenIfNeeded(int $serviceId, array &$credentials): bool
|
|
||||||
{
|
|
||||||
// No expiry set — nothing to refresh
|
|
||||||
if (empty($credentials['token_expires'])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Token not yet expired
|
|
||||||
if ((int) $credentials['token_expires'] >= time()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expired but no refresh token available
|
|
||||||
if (empty($credentials['refresh_token'])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look up the service type from DB
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('service_type'))
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . $serviceId);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$serviceType = $db->loadResult();
|
|
||||||
|
|
||||||
if (!$serviceType) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get OAuth config for this service type
|
|
||||||
$config = self::OAUTH_CONFIGS[$serviceType] ?? null;
|
|
||||||
|
|
||||||
if (!$config || empty($config['token_url'])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST refresh token grant
|
|
||||||
$postData = [
|
|
||||||
'grant_type' => 'refresh_token',
|
|
||||||
'refresh_token' => $credentials['refresh_token'],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Include client credentials if available
|
|
||||||
if (!empty($credentials['client_id'])) {
|
|
||||||
$postData['client_id'] = $credentials['client_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($credentials['client_secret'])) {
|
|
||||||
$postData['client_secret'] = $credentials['client_secret'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ch = curl_init($config['token_url']);
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => http_build_query($postData),
|
|
||||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded', 'Accept: application/json'],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 30,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if ($httpCode >= 200 && $httpCode < 300 && !empty($data['access_token'])) {
|
|
||||||
// Store updated token in DB
|
|
||||||
self::storeToken($serviceId, $data);
|
|
||||||
|
|
||||||
// Update credentials by reference
|
|
||||||
$credentials['access_token'] = $data['access_token'];
|
|
||||||
|
|
||||||
if (!empty($data['refresh_token'])) {
|
|
||||||
$credentials['refresh_token'] = $data['refresh_token'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['expires_in'])) {
|
|
||||||
$credentials['token_expires'] = time() + (int) $data['expires_in'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the OAuth callback URL for this Joomla installation.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getCallbackUrl(): string
|
|
||||||
{
|
|
||||||
return Uri::root() . 'administrator/index.php?option=com_mokojoomcross&task=oauth.callback';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,776 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Helper;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Component\ComponentHelper;
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\CMS\Uri\Uri;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Service\MokoJoomCrossServiceInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shared queue processor used by:
|
|
||||||
* - System plugin onAfterRender (page-load processing)
|
|
||||||
* - Task scheduler plugin (Joomla scheduled task)
|
|
||||||
*
|
|
||||||
* Handles: queued posts, failed retries, scheduled posts, and log cleanup.
|
|
||||||
* Uses a simple DB-based lock to prevent concurrent execution.
|
|
||||||
*/
|
|
||||||
class QueueProcessor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Process the post queue: dispatch queued posts, retry failed, fire scheduled.
|
|
||||||
*
|
|
||||||
* @param int $batchSize Max posts to process per run
|
|
||||||
*
|
|
||||||
* @return array ['processed' => int, 'succeeded' => int, 'failed' => int, 'skipped' => int]
|
|
||||||
*/
|
|
||||||
public static function processQueue(int $batchSize = 10): array
|
|
||||||
{
|
|
||||||
$result = ['processed' => 0, 'succeeded' => 0, 'failed' => 0, 'skipped' => 0];
|
|
||||||
|
|
||||||
if (!self::acquireLock()) {
|
|
||||||
$result['skipped'] = -1;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$componentParams = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
$maxRetry = (int) $componentParams->get('retry_max', 3);
|
|
||||||
$retryDelay = (int) $componentParams->get('retry_delay', 300);
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
// Build service plugin map
|
|
||||||
$pluginMap = self::getServicePluginMap();
|
|
||||||
|
|
||||||
// 1. Process queued posts
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('p.*, s.service_type, s.credentials, s.params AS service_params')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('INNER', $db->quoteName('#__mokojoomcross_services', 's')
|
|
||||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('p.service_id'))
|
|
||||||
->where($db->quoteName('p.status') . ' = ' . $db->quote('queued'))
|
|
||||||
->where('(' . $db->quoteName('p.scheduled_at') . ' IS NULL OR '
|
|
||||||
. $db->quoteName('p.scheduled_at') . ' <= ' . $db->quote($now) . ')')
|
|
||||||
->where($db->quoteName('s.published') . ' = 1')
|
|
||||||
->order($db->quoteName('p.created') . ' ASC')
|
|
||||||
->setLimit($batchSize);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$queuedPosts = $db->loadObjectList() ?: [];
|
|
||||||
|
|
||||||
// 2. Process failed posts eligible for retry (exponential backoff)
|
|
||||||
// Retry 1 waits retryDelay, retry 2 waits retryDelay*2, retry 3 waits retryDelay*4, etc.
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('p.*, s.service_type, s.credentials, s.params AS service_params')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('INNER', $db->quoteName('#__mokojoomcross_services', 's')
|
|
||||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('p.service_id'))
|
|
||||||
->where($db->quoteName('p.status') . ' = ' . $db->quote('failed'))
|
|
||||||
->where($db->quoteName('p.retry_count') . ' < ' . $maxRetry)
|
|
||||||
->where($db->quoteName('p.modified') . ' <= DATE_SUB(NOW(), INTERVAL ('
|
|
||||||
. (int) $retryDelay . ' * POW(2, ' . $db->quoteName('p.retry_count') . ')) SECOND)')
|
|
||||||
->where($db->quoteName('s.published') . ' = 1')
|
|
||||||
->order($db->quoteName('p.modified') . ' ASC')
|
|
||||||
->setLimit($batchSize);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$retryPosts = $db->loadObjectList() ?: [];
|
|
||||||
|
|
||||||
$allPosts = array_merge($queuedPosts, $retryPosts);
|
|
||||||
|
|
||||||
foreach ($allPosts as $post) {
|
|
||||||
$result['processed']++;
|
|
||||||
|
|
||||||
$plugin = $pluginMap[$post->service_type] ?? null;
|
|
||||||
|
|
||||||
if (!$plugin) {
|
|
||||||
$result['skipped']++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$isRetry = ($post->status === 'failed');
|
|
||||||
|
|
||||||
if ($isRetry) {
|
|
||||||
$newRetryCount = (int) $post->retry_count + 1;
|
|
||||||
|
|
||||||
// If this is the last retry attempt, mark permanently failed on failure
|
|
||||||
if ($newRetryCount >= $maxRetry) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('permanently_failed'))
|
|
||||||
->set($db->quoteName('retry_count') . ' = ' . $newRetryCount)
|
|
||||||
->set($db->quoteName('error_message') . ' = CONCAT(' . $db->quoteName('error_message') . ', ' . $db->quote(' [max retries exceeded]') . ')')
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, (int) $post->id, (int) $post->service_id, 'error',
|
|
||||||
sprintf('Permanently failed %s: max retries (%d) exceeded', $post->service_type, $maxRetry));
|
|
||||||
|
|
||||||
$result['failed']++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('retry_count') . ' = ' . $newRetryCount)
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark as posting
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('posting'))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
$credentials = json_decode($post->credentials ?: '{}', true) ?: [];
|
|
||||||
$params = json_decode($post->service_params ?: '{}', true) ?: [];
|
|
||||||
|
|
||||||
// Token auto-refresh before posting
|
|
||||||
OAuthHelper::refreshTokenIfNeeded((int) $post->service_id, $credentials);
|
|
||||||
|
|
||||||
// Extract intro image for media attachment
|
|
||||||
$media = [];
|
|
||||||
|
|
||||||
if (!empty($post->article_id)) {
|
|
||||||
$imgQuery = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('images'))
|
|
||||||
->from($db->quoteName('#__content'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->article_id);
|
|
||||||
$db->setQuery($imgQuery);
|
|
||||||
$imgJson = $db->loadResult();
|
|
||||||
|
|
||||||
if ($imgJson) {
|
|
||||||
$imgData = json_decode($imgJson);
|
|
||||||
|
|
||||||
if (!empty($imgData->image_intro)) {
|
|
||||||
$media[] = Uri::root() . ltrim($imgData->image_intro, '/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lifecycle event: before post
|
|
||||||
$cancel = false;
|
|
||||||
$message = $post->message;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$dispatcher = Factory::getApplication()->getDispatcher();
|
|
||||||
$beforeEvent = new \Joomla\Event\Event('onMokoJoomCrossBeforePost', [(int) $post->id, &$message, $post->service_type, &$cancel]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossBeforePost', $beforeEvent);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Dispatcher may not be available
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cancel) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('cancelled'))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, (int) $post->id, (int) $post->service_id, 'info',
|
|
||||||
sprintf('Post to %s cancelled by onMokoJoomCrossBeforePost event', $post->service_type));
|
|
||||||
|
|
||||||
$result['skipped']++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$apiResult = $plugin->publish($message, $media, $credentials, $params);
|
|
||||||
|
|
||||||
if (!empty($apiResult['success'])) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('posted'))
|
|
||||||
->set($db->quoteName('platform_post_id') . ' = ' . $db->quote($apiResult['platform_post_id'] ?? ''))
|
|
||||||
->set($db->quoteName('platform_response') . ' = ' . $db->quote(json_encode($apiResult['response'] ?? [])))
|
|
||||||
->set($db->quoteName('posted_at') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, (int) $post->id, (int) $post->service_id, 'info',
|
|
||||||
sprintf('%s to %s (ID: %s)', $isRetry ? 'Retry succeeded' : 'Posted', $post->service_type, $apiResult['platform_post_id'] ?? 'n/a'));
|
|
||||||
|
|
||||||
// Lifecycle event: after successful post
|
|
||||||
try {
|
|
||||||
$afterEvent = new \Joomla\Event\Event('onMokoJoomCrossAfterPost', [(int) $post->id, $post->service_type, $apiResult]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossAfterPost', $afterEvent);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Non-critical
|
|
||||||
}
|
|
||||||
|
|
||||||
$result['succeeded']++;
|
|
||||||
} else {
|
|
||||||
$errorMsg = $apiResult['response']['error'] ?? json_encode($apiResult['response'] ?? []);
|
|
||||||
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('failed'))
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(mb_substr($errorMsg, 0, 1000)))
|
|
||||||
->set($db->quoteName('platform_response') . ' = ' . $db->quote(json_encode($apiResult['response'] ?? [])))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, (int) $post->id, (int) $post->service_id, 'error',
|
|
||||||
sprintf('Failed %s: %s', $post->service_type, mb_substr($errorMsg, 0, 500)));
|
|
||||||
|
|
||||||
// Lifecycle event: post failed
|
|
||||||
try {
|
|
||||||
$failedEvent = new \Joomla\Event\Event('onMokoJoomCrossPostFailed', [(int) $post->id, $post->service_type, $errorMsg]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossPostFailed', $failedEvent);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Non-critical
|
|
||||||
}
|
|
||||||
|
|
||||||
$result['failed']++;
|
|
||||||
}
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$db->setQuery(
|
|
||||||
$db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('failed'))
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(mb_substr($e->getMessage(), 0, 1000)))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote(Factory::getDate()->toSql()))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $post->id)
|
|
||||||
);
|
|
||||||
$db->execute();
|
|
||||||
|
|
||||||
self::log($db, (int) $post->id, (int) $post->service_id, 'error',
|
|
||||||
sprintf('Exception %s: %s', $post->service_type, mb_substr($e->getMessage(), 0, 500)));
|
|
||||||
|
|
||||||
// Lifecycle event: post failed (exception)
|
|
||||||
try {
|
|
||||||
$failedEvent = new \Joomla\Event\Event('onMokoJoomCrossPostFailed', [(int) $post->id, $post->service_type, $e->getMessage()]);
|
|
||||||
$dispatcher->dispatch('onMokoJoomCrossPostFailed', $failedEvent);
|
|
||||||
} catch (\Throwable $ex) {
|
|
||||||
// Non-critical
|
|
||||||
}
|
|
||||||
|
|
||||||
$result['failed']++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Clean up old logs
|
|
||||||
self::cleanupLogs($db, $componentParams);
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
self::releaseLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Process evergreen re-shares: find articles marked as evergreen whose last
|
|
||||||
* successful post to each service was longer ago than the configured interval,
|
|
||||||
* and create new queue entries for them.
|
|
||||||
*
|
|
||||||
* @return array ['queued' => int]
|
|
||||||
*/
|
|
||||||
public static function processEvergreen(): array
|
|
||||||
{
|
|
||||||
$result = ['queued' => 0];
|
|
||||||
|
|
||||||
$componentParams = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
|
|
||||||
if (!$componentParams->get('evergreen_enabled', 1)) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$defaultInterval = (int) $componentParams->get('evergreen_default_interval', 30);
|
|
||||||
$maxPerRun = (int) $componentParams->get('evergreen_max_per_run', 3);
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
// Find published articles with evergreen=1 in attribs
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('c.id, c.attribs')
|
|
||||||
->from($db->quoteName('#__content', 'c'))
|
|
||||||
->where($db->quoteName('c.state') . ' = 1')
|
|
||||||
->where($db->quoteName('c.attribs') . ' LIKE ' . $db->quote('%"mokojoomcross_evergreen":"1"%'));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$articles = $db->loadObjectList() ?: [];
|
|
||||||
|
|
||||||
if (empty($articles)) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load all published services
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('id, service_type')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('published') . ' = 1');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$services = $db->loadObjectList() ?: [];
|
|
||||||
|
|
||||||
if (empty($services)) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import service plugins (not used for direct dispatch here, but ensures
|
|
||||||
// they are loaded in case any lifecycle events depend on them)
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
|
||||||
if ($result['queued'] >= $maxPerRun) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$attribs = json_decode($article->attribs ?? '{}', true) ?: [];
|
|
||||||
$interval = (int) ($attribs['mokojoomcross_evergreen_interval'] ?? $defaultInterval);
|
|
||||||
|
|
||||||
if ($interval < 1) {
|
|
||||||
$interval = $defaultInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Per-article service filter
|
|
||||||
$selectedServiceIds = $attribs['mokojoomcross_services'] ?? null;
|
|
||||||
|
|
||||||
if (is_array($selectedServiceIds) && !empty($selectedServiceIds)) {
|
|
||||||
$selectedServiceIds = array_map('intval', $selectedServiceIds);
|
|
||||||
} else {
|
|
||||||
$selectedServiceIds = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the full article for template rendering
|
|
||||||
$fullArticle = null;
|
|
||||||
|
|
||||||
foreach ($services as $service) {
|
|
||||||
if ($result['queued'] >= $maxPerRun) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Per-article service filter
|
|
||||||
if ($selectedServiceIds !== null && !in_array((int) $service->id, $selectedServiceIds, true)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check last successful post for this article+service
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('posted_at'))
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('article_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . (int) $service->id)
|
|
||||||
->where($db->quoteName('status') . ' = ' . $db->quote('posted'))
|
|
||||||
->order($db->quoteName('posted_at') . ' DESC')
|
|
||||||
->setLimit(1);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$lastPosted = $db->loadResult();
|
|
||||||
|
|
||||||
if (empty($lastPosted)) {
|
|
||||||
// Never posted — skip, the initial cross-post will handle it
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if interval has elapsed
|
|
||||||
$lastDate = Factory::getDate($lastPosted);
|
|
||||||
$dueDate = Factory::getDate($lastPosted . ' + ' . $interval . ' days');
|
|
||||||
|
|
||||||
if ($dueDate->toUnix() > Factory::getDate()->toUnix()) {
|
|
||||||
// Not due yet
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip if there's already a queued/posting entry
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('article_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . (int) $service->id)
|
|
||||||
->where($db->quoteName('status') . ' IN (' . $db->quote('queued') . ',' . $db->quote('posting') . ')');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
if ((int) $db->loadResult() > 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load full article if not already loaded
|
|
||||||
if ($fullArticle === null) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__content'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->id);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$fullArticle = $db->loadObject();
|
|
||||||
|
|
||||||
if (!$fullArticle) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render message using default template
|
|
||||||
$template = $componentParams->get('default_template', "{title}\n\n{url}");
|
|
||||||
$message = self::renderEvergreenMessage($db, $fullArticle, $template);
|
|
||||||
|
|
||||||
// Create queue entry
|
|
||||||
$post = (object) [
|
|
||||||
'article_id' => (int) $article->id,
|
|
||||||
'service_id' => (int) $service->id,
|
|
||||||
'status' => 'queued',
|
|
||||||
'message' => $message,
|
|
||||||
'platform_post_id' => '',
|
|
||||||
'platform_response' => '',
|
|
||||||
'error_message' => '',
|
|
||||||
'retry_count' => 0,
|
|
||||||
'created' => $now,
|
|
||||||
'modified' => $now,
|
|
||||||
];
|
|
||||||
|
|
||||||
$db->insertObject('#__mokojoomcross_posts', $post);
|
|
||||||
|
|
||||||
self::log($db, $db->insertid(), (int) $service->id, 'info',
|
|
||||||
sprintf('Evergreen re-share queued for article %d to %s (interval: %d days)',
|
|
||||||
$article->id, $service->service_type, $interval));
|
|
||||||
|
|
||||||
$result['queued']++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render a message for an evergreen re-share using the default template.
|
|
||||||
*/
|
|
||||||
private static function renderEvergreenMessage($db, object $article, string $template): string
|
|
||||||
{
|
|
||||||
$url = \Joomla\CMS\Uri\Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$url .= '&catid=' . $article->catid;
|
|
||||||
}
|
|
||||||
|
|
||||||
$categoryName = '';
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('title'))
|
|
||||||
->from($db->quoteName('#__categories'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->catid);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$categoryName = $db->loadResult() ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$authorName = '';
|
|
||||||
|
|
||||||
if (!empty($article->created_by)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('name'))
|
|
||||||
->from($db->quoteName('#__users'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $article->created_by);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$authorName = $db->loadResult() ?: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$introImage = '';
|
|
||||||
$images = json_decode($article->images ?? '{}');
|
|
||||||
|
|
||||||
if (!empty($images->image_intro)) {
|
|
||||||
$introImage = \Joomla\CMS\Uri\Uri::root() . ltrim($images->image_intro, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve article tags
|
|
||||||
$tagNames = [];
|
|
||||||
|
|
||||||
if (!empty($article->id)) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select($db->quoteName('t.title'))
|
|
||||||
->from($db->quoteName('#__tags', 't'))
|
|
||||||
->join('INNER', $db->quoteName('#__contentitem_tag_map', 'm')
|
|
||||||
. ' ON ' . $db->quoteName('m.tag_id') . ' = ' . $db->quoteName('t.id'))
|
|
||||||
->where($db->quoteName('m.type_alias') . ' = ' . $db->quote('com_content.article'))
|
|
||||||
->where($db->quoteName('m.content_item_id') . ' = ' . (int) $article->id)
|
|
||||||
->where($db->quoteName('t.published') . ' = 1');
|
|
||||||
$db->setQuery($query);
|
|
||||||
$tagNames = $db->loadColumn() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tagsComma = implode(', ', $tagNames);
|
|
||||||
$hashtags = implode(' ', array_map(function ($tag) {
|
|
||||||
return '#' . preg_replace('/\s+/', '', $tag);
|
|
||||||
}, $tagNames));
|
|
||||||
|
|
||||||
$replacements = [
|
|
||||||
'{title}' => $article->title ?? '',
|
|
||||||
'{introtext}' => strip_tags(mb_substr($article->introtext ?? '', 0, 280)),
|
|
||||||
'{fulltext}' => strip_tags(mb_substr($article->fulltext ?? '', 0, 500)),
|
|
||||||
'{url}' => $url,
|
|
||||||
'{image}' => $introImage,
|
|
||||||
'{category}' => $categoryName,
|
|
||||||
'{author}' => $authorName,
|
|
||||||
'{date}' => Factory::getDate($article->publish_up ?? 'now')->format('Y-m-d'),
|
|
||||||
'{tags}' => $tagsComma,
|
|
||||||
'{hashtags}' => $hashtags,
|
|
||||||
];
|
|
||||||
|
|
||||||
$message = str_replace(array_keys($replacements), array_values($replacements), $template);
|
|
||||||
|
|
||||||
// Resolve custom field placeholders: {field:field_name}
|
|
||||||
$message = preg_replace_callback('/\{field:([a-zA-Z0-9_-]+)\}/', function ($matches) use ($db, $article) {
|
|
||||||
$fieldName = $matches[1];
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('fv.value')
|
|
||||||
->from($db->quoteName('#__fields_values', 'fv'))
|
|
||||||
->join('INNER', $db->quoteName('#__fields', 'f') . ' ON f.id = fv.field_id')
|
|
||||||
->where('f.name = ' . $db->quote($fieldName))
|
|
||||||
->where('fv.item_id = ' . (int) $article->id);
|
|
||||||
$db->setQuery($query);
|
|
||||||
return $db->loadResult() ?: '';
|
|
||||||
}, $message);
|
|
||||||
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manually retry one or more failed/permanently_failed posts.
|
|
||||||
*
|
|
||||||
* Resets status to 'queued' and retry_count to 0 so the queue processor
|
|
||||||
* picks them up on the next run.
|
|
||||||
*
|
|
||||||
* @param array $postIds Post IDs to retry
|
|
||||||
*
|
|
||||||
* @return int Number of posts re-queued
|
|
||||||
*/
|
|
||||||
public static function retryPosts(array $postIds): int
|
|
||||||
{
|
|
||||||
if (empty($postIds)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
$ids = implode(',', array_map('intval', $postIds));
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('queued'))
|
|
||||||
->set($db->quoteName('retry_count') . ' = 0')
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(''))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote($now))
|
|
||||||
->where($db->quoteName('id') . ' IN (' . $ids . ')')
|
|
||||||
->where($db->quoteName('status') . ' IN (' . $db->quote('failed') . ',' . $db->quote('permanently_failed') . ')');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
$count = $db->getAffectedRows();
|
|
||||||
|
|
||||||
if ($count > 0) {
|
|
||||||
self::log($db, null, null, 'info', sprintf('Manual retry: %d post(s) re-queued', $count));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retry all failed posts for a specific service.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service ID
|
|
||||||
*
|
|
||||||
* @return int Number of posts re-queued
|
|
||||||
*/
|
|
||||||
public static function retryService(int $serviceId): int
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->update($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->set($db->quoteName('status') . ' = ' . $db->quote('queued'))
|
|
||||||
->set($db->quoteName('retry_count') . ' = 0')
|
|
||||||
->set($db->quoteName('error_message') . ' = ' . $db->quote(''))
|
|
||||||
->set($db->quoteName('modified') . ' = ' . $db->quote($now))
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . $serviceId)
|
|
||||||
->where($db->quoteName('status') . ' IN (' . $db->quote('failed') . ',' . $db->quote('permanently_failed') . ')');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
$count = $db->getAffectedRows();
|
|
||||||
|
|
||||||
if ($count > 0) {
|
|
||||||
self::log($db, null, $serviceId, 'info', sprintf('Bulk retry: %d post(s) re-queued for service %d', $count, $serviceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if there are pending items in the queue.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function hasPendingWork(): bool
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
$componentParams = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
$maxRetry = (int) $componentParams->get('retry_max', 3);
|
|
||||||
$retryDelay = (int) $componentParams->get('retry_delay', 300);
|
|
||||||
$retryAfter = Factory::getDate('now - ' . $retryDelay . ' seconds')->toSql();
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
// Queued posts ready to go
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('status') . ' = ' . $db->quote('queued'))
|
|
||||||
->where('(' . $db->quoteName('scheduled_at') . ' IS NULL OR '
|
|
||||||
. $db->quoteName('scheduled_at') . ' <= ' . $db->quote($now) . ')');
|
|
||||||
$db->setQuery($query);
|
|
||||||
$queued = (int) $db->loadResult();
|
|
||||||
|
|
||||||
// Failed posts eligible for retry
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('status') . ' = ' . $db->quote('failed'))
|
|
||||||
->where($db->quoteName('retry_count') . ' < ' . $maxRetry)
|
|
||||||
->where($db->quoteName('modified') . ' <= ' . $db->quote($retryAfter));
|
|
||||||
$db->setQuery($query);
|
|
||||||
$retryable = (int) $db->loadResult();
|
|
||||||
|
|
||||||
return ($queued + $retryable) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Import mokojoomcross plugins and build a type → plugin instance map.
|
|
||||||
*
|
|
||||||
* @return array<string, MokoJoomCrossServiceInterface>
|
|
||||||
*/
|
|
||||||
private static function getServicePluginMap(): array
|
|
||||||
{
|
|
||||||
PluginHelper::importPlugin('mokojoomcross');
|
|
||||||
|
|
||||||
// In Joomla 5+ with SubscriberInterface, plugins receive the Event object
|
|
||||||
// as their first argument. When they do $services[] = $this, they append to
|
|
||||||
// the Event via ArrayAccess at numeric indices starting at 1.
|
|
||||||
$servicePlugins = [];
|
|
||||||
$event = new \Joomla\Event\Event('onMokoJoomCrossGetServices', [$servicePlugins]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Factory::getApplication()->getDispatcher()->dispatch(
|
|
||||||
'onMokoJoomCrossGetServices',
|
|
||||||
$event
|
|
||||||
);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Dispatcher may not be available in all contexts
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read plugins back from the Event's ArrayAccess indices
|
|
||||||
$idx = 1;
|
|
||||||
|
|
||||||
while (isset($event[$idx])) {
|
|
||||||
$servicePlugins[] = $event[$idx];
|
|
||||||
$idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$map = [];
|
|
||||||
|
|
||||||
foreach ($servicePlugins as $plugin) {
|
|
||||||
if ($plugin instanceof MokoJoomCrossServiceInterface) {
|
|
||||||
$map[$plugin->getServiceType()] = $plugin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete logs older than the configured retention period.
|
|
||||||
*/
|
|
||||||
private static function cleanupLogs($db, $componentParams): void
|
|
||||||
{
|
|
||||||
$retentionDays = (int) $componentParams->get('log_retention_days', 90);
|
|
||||||
|
|
||||||
if ($retentionDays <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cutoff = Factory::getDate('now - ' . $retentionDays . ' days')->toSql();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->delete($db->quoteName('#__mokojoomcross_logs'))
|
|
||||||
->where($db->quoteName('created') . ' < ' . $db->quote($cutoff));
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Acquire a MySQL advisory lock to prevent concurrent queue processing.
|
|
||||||
*
|
|
||||||
* Uses GET_LOCK() which is atomic — no race condition possible.
|
|
||||||
* The 0 timeout means non-blocking (returns immediately if lock is held).
|
|
||||||
* MySQL automatically releases the lock if the connection drops.
|
|
||||||
*/
|
|
||||||
private static function acquireLock(): bool
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$db->setQuery("SELECT GET_LOCK('mokojoomcross_queue', 0)");
|
|
||||||
|
|
||||||
return (int) $db->loadResult() === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Release the MySQL advisory lock.
|
|
||||||
*/
|
|
||||||
private static function releaseLock(): void
|
|
||||||
{
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
$db->setQuery("SELECT RELEASE_LOCK('mokojoomcross_queue')");
|
|
||||||
$db->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write a log entry.
|
|
||||||
*/
|
|
||||||
private static function log($db, ?int $postId, ?int $serviceId, string $level, string $message): void
|
|
||||||
{
|
|
||||||
$log = (object) [
|
|
||||||
'post_id' => $postId,
|
|
||||||
'service_id' => $serviceId,
|
|
||||||
'level' => $level,
|
|
||||||
'message' => mb_substr($message, 0, 2000),
|
|
||||||
'context' => '{}',
|
|
||||||
'created' => Factory::getDate()->toSql(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$db->insertObject('#__mokojoomcross_logs', $log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Helper;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static helper that maps service types to Joomla Bootstrap icons.
|
|
||||||
*/
|
|
||||||
class ServiceIconHelper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Map of service type identifiers to icon CSS classes.
|
|
||||||
*
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
private const ICONS = [
|
|
||||||
// Social
|
|
||||||
'facebook' => 'icon-facebook',
|
|
||||||
'twitter' => 'icon-twitter',
|
|
||||||
'linkedin' => 'icon-linkedin',
|
|
||||||
'mastodon' => 'icon-globe',
|
|
||||||
'bluesky' => 'icon-cloud',
|
|
||||||
'threads' => 'icon-comments',
|
|
||||||
'pinterest' => 'icon-thumbtack',
|
|
||||||
'reddit' => 'icon-comments-alt',
|
|
||||||
'tumblr' => 'icon-pencil-alt',
|
|
||||||
'tiktok' => 'icon-play-circle',
|
|
||||||
'nostr' => 'icon-key',
|
|
||||||
'activitypub' => 'icon-network-wired',
|
|
||||||
// Chat
|
|
||||||
'telegram' => 'icon-paper-plane',
|
|
||||||
'discord' => 'icon-headset',
|
|
||||||
'slack' => 'icon-hashtag',
|
|
||||||
'teams' => 'icon-users',
|
|
||||||
'googlechat' => 'icon-comment',
|
|
||||||
'whatsapp' => 'icon-mobile',
|
|
||||||
'matrix' => 'icon-th',
|
|
||||||
'ntfy' => 'icon-bell',
|
|
||||||
// Email
|
|
||||||
'mailchimp' => 'icon-envelope',
|
|
||||||
'sendgrid' => 'icon-envelope-open',
|
|
||||||
'brevo' => 'icon-at',
|
|
||||||
'convertkit' => 'icon-mail-bulk',
|
|
||||||
'constantcontact' => 'icon-address-book',
|
|
||||||
// Publishing
|
|
||||||
'medium' => 'icon-book',
|
|
||||||
'wordpress' => 'icon-blog',
|
|
||||||
'devto' => 'icon-code',
|
|
||||||
'ghost' => 'icon-ghost',
|
|
||||||
'hashnode' => 'icon-newspaper',
|
|
||||||
'blogger' => 'icon-rss',
|
|
||||||
// Business
|
|
||||||
'googlebusiness' => 'icon-store',
|
|
||||||
// Universal
|
|
||||||
'webhook' => 'icon-plug',
|
|
||||||
'rssfeed' => 'icon-rss-square',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the icon CSS class for a service type.
|
|
||||||
*
|
|
||||||
* @param string $serviceType The service type identifier
|
|
||||||
*
|
|
||||||
* @return string Icon CSS class
|
|
||||||
*/
|
|
||||||
public static function getIcon(string $serviceType): string
|
|
||||||
{
|
|
||||||
return self::ICONS[$serviceType] ?? 'icon-share-alt';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render an icon span element for a service type.
|
|
||||||
*
|
|
||||||
* @param string $serviceType The service type identifier
|
|
||||||
* @param string $extraClass Additional CSS classes to append
|
|
||||||
*
|
|
||||||
* @return string HTML span element
|
|
||||||
*/
|
|
||||||
public static function renderIcon(string $serviceType, string $extraClass = ''): string
|
|
||||||
{
|
|
||||||
$icon = self::getIcon($serviceType);
|
|
||||||
$class = trim($icon . ' ' . htmlspecialchars($extraClass, ENT_QUOTES, 'UTF-8'));
|
|
||||||
|
|
||||||
return '<span class="' . $class . '" aria-hidden="true"></span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,127 +70,4 @@ class DashboardModel extends BaseDatabaseModel
|
|||||||
|
|
||||||
return !empty($params['migration_available']);
|
return !empty($params['migration_available']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get recent activity log entries.
|
|
||||||
*
|
|
||||||
* @param int $limit Number of entries to return
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getRecentActivity(int $limit = 10): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('l.*, s.title AS service_title, s.service_type')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_logs', 'l'))
|
|
||||||
->join('LEFT', $db->quoteName('#__mokojoomcross_services', 's')
|
|
||||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('l.service_id'))
|
|
||||||
->order($db->quoteName('l.created') . ' DESC');
|
|
||||||
|
|
||||||
$db->setQuery($query, 0, $limit);
|
|
||||||
|
|
||||||
return $db->loadObjectList() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get posts-per-service breakdown for the analytics chart.
|
|
||||||
*
|
|
||||||
* @param string|null $since Only count posts created on or after this datetime
|
|
||||||
*
|
|
||||||
* @return array [['service_type' => '...', 'posted' => N, 'failed' => N, 'queued' => N], ...]
|
|
||||||
*/
|
|
||||||
public function getServiceBreakdown(?string $since = null): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
$db->quoteName('s.id', 'service_id'),
|
|
||||||
$db->quoteName('s.service_type'),
|
|
||||||
$db->quoteName('s.title', 'service_title'),
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS posted',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('failed') . ' THEN 1 ELSE 0 END) AS failed',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('queued') . ' THEN 1 ELSE 0 END) AS queued',
|
|
||||||
'COUNT(*) AS total',
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('INNER', $db->quoteName('#__mokojoomcross_services', 's')
|
|
||||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('p.service_id'))
|
|
||||||
->group($db->quoteName(['s.id', 's.service_type', 's.title']))
|
|
||||||
->order('total DESC');
|
|
||||||
|
|
||||||
if ($since !== null) {
|
|
||||||
$query->where($db->quoteName('p.created') . ' >= ' . $db->quote($since));
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
return $db->loadAssocList() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get posts-per-day for the last N days (for trend chart).
|
|
||||||
*
|
|
||||||
* @param int $days Number of days to look back
|
|
||||||
*
|
|
||||||
* @return array [['day' => '2026-05-28', 'posted' => N, 'failed' => N], ...]
|
|
||||||
*/
|
|
||||||
public function getDailyTrend(int $days = 14): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$cutoff = Factory::getDate('now - ' . $days . ' days')->format('Y-m-d');
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
'DATE(' . $db->quoteName('created') . ') AS day',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS posted',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('failed') . ' THEN 1 ELSE 0 END) AS failed',
|
|
||||||
'COUNT(*) AS total',
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where('DATE(' . $db->quoteName('created') . ') >= ' . $db->quote($cutoff))
|
|
||||||
->group('DATE(' . $db->quoteName('created') . ')')
|
|
||||||
->order('day ASC');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
return $db->loadAssocList() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get most cross-posted articles.
|
|
||||||
*
|
|
||||||
* @param int $limit Number of articles
|
|
||||||
* @param string|null $since Only count posts created on or after this datetime
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTopArticles(int $limit = 5, ?string $since = null): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
$db->quoteName('c.id'),
|
|
||||||
$db->quoteName('c.title'),
|
|
||||||
'COUNT(*) AS post_count',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS success_count',
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('INNER', $db->quoteName('#__content', 'c')
|
|
||||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('p.article_id'))
|
|
||||||
->group($db->quoteName(['c.id', 'c.title']))
|
|
||||||
->order('post_count DESC');
|
|
||||||
|
|
||||||
if ($since !== null) {
|
|
||||||
$query->where($db->quoteName('p.created') . ' >= ' . $db->quote($since));
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->setQuery($query, 0, $limit);
|
|
||||||
|
|
||||||
return $db->loadAssocList() ?: [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Model;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\MVC\Model\AdminModel;
|
|
||||||
|
|
||||||
class PostModel extends AdminModel
|
|
||||||
{
|
|
||||||
public function getForm($data = [], $loadData = true)
|
|
||||||
{
|
|
||||||
$form = $this->loadForm(
|
|
||||||
'com_mokojoomcross.post',
|
|
||||||
'post',
|
|
||||||
['control' => 'jform', 'load_data' => $loadData]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (empty($form)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock article_id and service_id on existing records
|
|
||||||
$id = $this->getState('post.id', 0);
|
|
||||||
|
|
||||||
if ($id > 0) {
|
|
||||||
$form->setFieldAttribute('article_id', 'readonly', 'true');
|
|
||||||
$form->setFieldAttribute('service_id', 'readonly', 'true');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function loadFormData()
|
|
||||||
{
|
|
||||||
return $this->getItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare and sanitise the table prior to saving.
|
|
||||||
*/
|
|
||||||
protected function prepareTable($table)
|
|
||||||
{
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
if (empty($table->id)) {
|
|
||||||
$table->created = $now;
|
|
||||||
$table->modified = $now;
|
|
||||||
|
|
||||||
if (empty($table->status)) {
|
|
||||||
$table->status = empty($table->scheduled_at) ? 'queued' : 'scheduled';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($table->retry_count)) {
|
|
||||||
$table->retry_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($table->platform_post_id)) {
|
|
||||||
$table->platform_post_id = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($table->platform_response)) {
|
|
||||||
$table->platform_response = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($table->error_message)) {
|
|
||||||
$table->error_message = '';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$table->modified = $now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -65,22 +65,6 @@ class PostsModel extends ListModel
|
|||||||
$query->where($db->quoteName('a.status') . ' = ' . $db->quote($status));
|
$query->where($db->quoteName('a.status') . ' = ' . $db->quote($status));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by service
|
|
||||||
$serviceId = $this->getState('filter.service_id');
|
|
||||||
|
|
||||||
if (!empty($serviceId)) {
|
|
||||||
$query->where($db->quoteName('a.service_id') . ' = ' . (int) $serviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by search (article title or message content)
|
|
||||||
$search = $this->getState('filter.search');
|
|
||||||
|
|
||||||
if (!empty($search)) {
|
|
||||||
$search = '%' . $db->escape(trim($search), true) . '%';
|
|
||||||
$query->where('(' . $db->quoteName('c.title') . ' LIKE ' . $db->quote($search)
|
|
||||||
. ' OR ' . $db->quoteName('a.message') . ' LIKE ' . $db->quote($search) . ')');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ordering
|
// Ordering
|
||||||
$orderCol = $this->state->get('list.ordering', 'a.created');
|
$orderCol = $this->state->get('list.ordering', 'a.created');
|
||||||
$orderDirn = $this->state->get('list.direction', 'DESC');
|
$orderDirn = $this->state->get('list.direction', 'DESC');
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ namespace Joomla\Component\MokoJoomCross\Administrator\Model;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Filter\OutputFilter;
|
|
||||||
use Joomla\CMS\MVC\Model\AdminModel;
|
use Joomla\CMS\MVC\Model\AdminModel;
|
||||||
|
|
||||||
class ServiceModel extends AdminModel
|
class ServiceModel extends AdminModel
|
||||||
@@ -45,77 +43,12 @@ class ServiceModel extends AdminModel
|
|||||||
/**
|
/**
|
||||||
* Method to get the data that should be injected in the form.
|
* Method to get the data that should be injected in the form.
|
||||||
*
|
*
|
||||||
* Expands the JSON credentials column back into individual cred_* form fields
|
|
||||||
* so they are populated when editing an existing service.
|
|
||||||
*
|
|
||||||
* @return mixed The data for the form
|
* @return mixed The data for the form
|
||||||
*/
|
*/
|
||||||
protected function loadFormData()
|
protected function loadFormData()
|
||||||
{
|
{
|
||||||
$data = $this->getItem();
|
$data = $this->getItem();
|
||||||
|
|
||||||
if ($data && !empty($data->credentials)) {
|
|
||||||
$credentials = json_decode($data->credentials, true) ?: [];
|
|
||||||
$serviceType = $data->service_type ?? '';
|
|
||||||
|
|
||||||
foreach ($credentials as $key => $value) {
|
|
||||||
// Map credential keys back to form field names.
|
|
||||||
// The mode field has no service type prefix.
|
|
||||||
if ($key === 'mode') {
|
|
||||||
$data->cred_mode = $value;
|
|
||||||
} else {
|
|
||||||
$data->{'cred_' . $serviceType . '_' . $key} = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Override save to collect cred_* form fields into the credentials JSON column.
|
|
||||||
*
|
|
||||||
* The service form has individual fields (cred_twitter_api_key, cred_facebook_page_id, etc.)
|
|
||||||
* but the database stores them as a single JSON blob in the `credentials` column.
|
|
||||||
*
|
|
||||||
* @param array $data The form data
|
|
||||||
*
|
|
||||||
* @return boolean True on success
|
|
||||||
*/
|
|
||||||
public function save($data)
|
|
||||||
{
|
|
||||||
$serviceType = $data['service_type'] ?? '';
|
|
||||||
$credentials = [];
|
|
||||||
$credPrefix = 'cred_';
|
|
||||||
|
|
||||||
// Collect all cred_* fields into the credentials array
|
|
||||||
foreach ($data as $key => $value) {
|
|
||||||
if (strpos($key, $credPrefix) !== 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$credKey = substr($key, strlen($credPrefix));
|
|
||||||
|
|
||||||
// The mode field is shared across service types (no service_type prefix)
|
|
||||||
if ($credKey === 'mode') {
|
|
||||||
$credentials['mode'] = $value;
|
|
||||||
} elseif ($serviceType && strpos($credKey, $serviceType . '_') === 0) {
|
|
||||||
// Strip the service_type prefix: cred_twitter_api_key -> api_key
|
|
||||||
$strippedKey = substr($credKey, strlen($serviceType) + 1);
|
|
||||||
$credentials[$strippedKey] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the credentials JSON
|
|
||||||
$data['credentials'] = !empty($credentials) ? json_encode($credentials) : '{}';
|
|
||||||
|
|
||||||
// Remove individual cred_* fields so they don't cause column-not-found errors
|
|
||||||
foreach (array_keys($data) as $key) {
|
|
||||||
if (strpos($key, $credPrefix) === 0) {
|
|
||||||
unset($data[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::save($data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,185 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Model;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Per-service analytics drill-down model.
|
|
||||||
*/
|
|
||||||
class ServiceStatsModel extends BaseDatabaseModel
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the service ID from the request.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getServiceId(): int
|
|
||||||
{
|
|
||||||
return Factory::getApplication()->input->getInt('id', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a single service record by ID.
|
|
||||||
*
|
|
||||||
* @param int $id Service ID
|
|
||||||
*
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public function getService(int $id = 0): ?object
|
|
||||||
{
|
|
||||||
if ($id === 0) {
|
|
||||||
$id = $this->getServiceId();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($id === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('id') . ' = ' . (int) $id);
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
return $db->loadObject() ?: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get post status counts for a specific service.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service ID
|
|
||||||
*
|
|
||||||
* @return object Object with total, posted, failed, queued properties
|
|
||||||
*/
|
|
||||||
public function getPostStats(int $serviceId): object
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$stats = new \stdClass();
|
|
||||||
|
|
||||||
foreach (['queued', 'posted', 'failed'] as $status) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('COUNT(*)')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . (int) $serviceId)
|
|
||||||
->where($db->quoteName('status') . ' = ' . $db->quote($status));
|
|
||||||
$db->setQuery($query);
|
|
||||||
$stats->{$status} = (int) $db->loadResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
$stats->total = $stats->queued + $stats->posted + $stats->failed;
|
|
||||||
|
|
||||||
return $stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get daily post trend for a specific service.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service ID
|
|
||||||
* @param int $days Number of days to look back
|
|
||||||
*
|
|
||||||
* @return array [['day' => '2026-05-28', 'posted' => N, 'failed' => N], ...]
|
|
||||||
*/
|
|
||||||
public function getDailyTrend(int $serviceId, int $days = 30): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$cutoff = Factory::getDate('now - ' . $days . ' days')->format('Y-m-d');
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
'DATE(' . $db->quoteName('created') . ') AS day',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS posted',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('failed') . ' THEN 1 ELSE 0 END) AS failed',
|
|
||||||
'COUNT(*) AS total',
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts'))
|
|
||||||
->where($db->quoteName('service_id') . ' = ' . (int) $serviceId)
|
|
||||||
->where('DATE(' . $db->quoteName('created') . ') >= ' . $db->quote($cutoff))
|
|
||||||
->group('DATE(' . $db->quoteName('created') . ')')
|
|
||||||
->order('day ASC');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
|
|
||||||
return $db->loadAssocList() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get recent posts for a specific service with article titles.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service ID
|
|
||||||
* @param int $limit Number of posts to return
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getRecentPosts(int $serviceId, int $limit = 20): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
$db->quoteName('p.id'),
|
|
||||||
$db->quoteName('p.status'),
|
|
||||||
$db->quoteName('p.posted_at'),
|
|
||||||
$db->quoteName('p.created'),
|
|
||||||
$db->quoteName('p.error_message'),
|
|
||||||
$db->quoteName('p.retry_count'),
|
|
||||||
$db->quoteName('c.title', 'article_title'),
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('LEFT', $db->quoteName('#__content', 'c')
|
|
||||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('p.article_id'))
|
|
||||||
->where($db->quoteName('p.service_id') . ' = ' . (int) $serviceId)
|
|
||||||
->order($db->quoteName('p.created') . ' DESC');
|
|
||||||
|
|
||||||
$db->setQuery($query, 0, $limit);
|
|
||||||
|
|
||||||
return $db->loadAssocList() ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the most cross-posted articles for a specific service.
|
|
||||||
*
|
|
||||||
* @param int $serviceId Service ID
|
|
||||||
* @param int $limit Number of articles to return
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTopArticles(int $serviceId, int $limit = 10): array
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select([
|
|
||||||
$db->quoteName('c.id'),
|
|
||||||
$db->quoteName('c.title'),
|
|
||||||
'COUNT(*) AS post_count',
|
|
||||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS success_count',
|
|
||||||
])
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('INNER', $db->quoteName('#__content', 'c')
|
|
||||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('p.article_id'))
|
|
||||||
->where($db->quoteName('p.service_id') . ' = ' . (int) $serviceId)
|
|
||||||
->group($db->quoteName(['c.id', 'c.title']))
|
|
||||||
->order('post_count DESC');
|
|
||||||
|
|
||||||
$db->setQuery($query, 0, $limit);
|
|
||||||
|
|
||||||
return $db->loadAssocList() ?: [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Model;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\Model\AdminModel;
|
|
||||||
|
|
||||||
class TemplateModel extends AdminModel
|
|
||||||
{
|
|
||||||
public function getForm($data = [], $loadData = true)
|
|
||||||
{
|
|
||||||
$form = $this->loadForm(
|
|
||||||
'com_mokojoomcross.template',
|
|
||||||
'template',
|
|
||||||
['control' => 'jform', 'load_data' => $loadData]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (empty($form)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function loadFormData()
|
|
||||||
{
|
|
||||||
return $this->getItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Model;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\Model\ListModel;
|
|
||||||
|
|
||||||
class TemplatesModel extends ListModel
|
|
||||||
{
|
|
||||||
public function __construct($config = [])
|
|
||||||
{
|
|
||||||
if (empty($config['filter_fields'])) {
|
|
||||||
$config['filter_fields'] = [
|
|
||||||
'id', 'a.id',
|
|
||||||
'title', 'a.title',
|
|
||||||
'service_type', 'a.service_type',
|
|
||||||
'published', 'a.published',
|
|
||||||
'ordering', 'a.ordering',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::__construct($config);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getListQuery()
|
|
||||||
{
|
|
||||||
$db = $this->getDatabase();
|
|
||||||
$query = $db->getQuery(true);
|
|
||||||
|
|
||||||
$query->select('a.*')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_templates', 'a'));
|
|
||||||
|
|
||||||
$published = $this->getState('filter.published');
|
|
||||||
|
|
||||||
if (is_numeric($published)) {
|
|
||||||
$query->where($db->quoteName('a.published') . ' = ' . (int) $published);
|
|
||||||
}
|
|
||||||
|
|
||||||
$serviceType = $this->getState('filter.service_type');
|
|
||||||
|
|
||||||
if (!empty($serviceType)) {
|
|
||||||
$query->where($db->quoteName('a.service_type') . ' = ' . $db->quote($serviceType));
|
|
||||||
}
|
|
||||||
|
|
||||||
$orderCol = $this->state->get('list.ordering', 'a.ordering');
|
|
||||||
$orderDirn = $this->state->get('list.direction', 'ASC');
|
|
||||||
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn));
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,15 +70,4 @@ interface MokoJoomCrossServiceInterface
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function supportsMedia(): bool;
|
public function supportsMedia(): bool;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the media types this service supports.
|
|
||||||
*
|
|
||||||
* Return an array of supported types: 'image', 'video', 'gif', 'document'.
|
|
||||||
* Services that return an empty array are text-only.
|
|
||||||
* Default implementation returns ['image'] if supportsMedia() is true.
|
|
||||||
*
|
|
||||||
* @return string[] e.g. ['image', 'video', 'gif']
|
|
||||||
*/
|
|
||||||
public function getSupportedMediaTypes(): array;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ namespace Joomla\Component\MokoJoomCross\Administrator\Table;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Filter\OutputFilter;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Table\Table;
|
use Joomla\CMS\Table\Table;
|
||||||
use Joomla\Database\DatabaseDriver;
|
use Joomla\Database\DatabaseDriver;
|
||||||
|
|
||||||
@@ -25,67 +22,4 @@ class ServiceTable extends Table
|
|||||||
{
|
{
|
||||||
parent::__construct('#__mokojoomcross_services', 'id', $db);
|
parent::__construct('#__mokojoomcross_services', 'id', $db);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate the record before storing.
|
|
||||||
*
|
|
||||||
* Generates alias from title if empty, validates required fields,
|
|
||||||
* sets created/modified timestamps.
|
|
||||||
*
|
|
||||||
* @return boolean True if the record is valid
|
|
||||||
*/
|
|
||||||
public function check(): bool
|
|
||||||
{
|
|
||||||
// Title is required
|
|
||||||
if (empty($this->title)) {
|
|
||||||
$this->setError(Text::_('COM_MOKOJOOMCROSS_ERROR_TITLE_REQUIRED'));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Service type is required
|
|
||||||
if (empty($this->service_type)) {
|
|
||||||
$this->setError(Text::_('COM_MOKOJOOMCROSS_ERROR_SERVICE_TYPE_REQUIRED'));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate alias from title if empty
|
|
||||||
if (empty($this->alias)) {
|
|
||||||
$this->alias = $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->alias = OutputFilter::stringURLSafe($this->alias);
|
|
||||||
|
|
||||||
// Make sure alias is unique
|
|
||||||
if (empty($this->alias)) {
|
|
||||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set timestamps
|
|
||||||
$now = Factory::getDate()->toSql();
|
|
||||||
|
|
||||||
if (empty($this->created)) {
|
|
||||||
$this->created = $now;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->modified = $now;
|
|
||||||
|
|
||||||
// Set created_by if not set
|
|
||||||
if (empty($this->created_by)) {
|
|
||||||
$this->created_by = Factory::getApplication()->getIdentity()->id ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure credentials is valid JSON
|
|
||||||
if (empty($this->credentials)) {
|
|
||||||
$this->credentials = '{}';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure params is valid JSON
|
|
||||||
if (empty($this->params)) {
|
|
||||||
$this->params = '{}';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\Table;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Table\Table;
|
|
||||||
use Joomla\Database\DatabaseDriver;
|
|
||||||
|
|
||||||
class TemplateTable extends Table
|
|
||||||
{
|
|
||||||
public function __construct(DatabaseDriver $db)
|
|
||||||
{
|
|
||||||
parent::__construct('#__mokojoomcross_templates', 'id', $db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,53 +13,21 @@ namespace Joomla\Component\MokoJoomCross\Administrator\View\Dashboard;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\MokoJoomCrossHelper;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
{
|
{
|
||||||
protected $stats;
|
protected $stats;
|
||||||
protected $migrationAvailable;
|
protected $migrationAvailable;
|
||||||
protected $recentActivity;
|
|
||||||
protected $serviceBreakdown;
|
|
||||||
protected $dailyTrend;
|
|
||||||
protected $topArticles;
|
|
||||||
public $sidebar;
|
|
||||||
public $period;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
public function display($tpl = null): void
|
||||||
{
|
{
|
||||||
$model = $this->getModel();
|
$this->stats = $this->get('Stats');
|
||||||
|
|
||||||
// Read period parameter for date range filtering
|
|
||||||
$this->period = Factory::getApplication()->input->getInt('period', 30);
|
|
||||||
$validPeriods = [7, 30, 90, 0];
|
|
||||||
|
|
||||||
if (!in_array($this->period, $validPeriods, true)) {
|
|
||||||
$this->period = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the since date based on period (0 = all time)
|
|
||||||
$since = null;
|
|
||||||
|
|
||||||
if ($this->period > 0) {
|
|
||||||
$since = Factory::getDate('now - ' . $this->period . ' days')->toSql();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->stats = $this->get('Stats');
|
|
||||||
$this->migrationAvailable = $this->get('MigrationAvailable');
|
$this->migrationAvailable = $this->get('MigrationAvailable');
|
||||||
$this->recentActivity = $model->getRecentActivity(10);
|
|
||||||
$this->serviceBreakdown = $model->getServiceBreakdown($since);
|
|
||||||
$this->dailyTrend = $model->getDailyTrend($this->period ?: 365);
|
|
||||||
$this->topArticles = $model->getTopArticles(5, $since);
|
|
||||||
|
|
||||||
$this->addToolbar();
|
$this->addToolbar();
|
||||||
|
|
||||||
MokoJoomCrossHelper::addSubmenu('dashboard');
|
|
||||||
$this->sidebar = \Joomla\CMS\HTML\Sidebar::render();
|
|
||||||
|
|
||||||
parent::display($tpl);
|
parent::display($tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace Joomla\Component\MokoJoomCross\Administrator\View\Logs;
|
|||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
@@ -23,16 +21,12 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected $items;
|
protected $items;
|
||||||
protected $pagination;
|
protected $pagination;
|
||||||
protected $state;
|
protected $state;
|
||||||
public $filterForm;
|
|
||||||
public $activeFilters;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
public function display($tpl = null): void
|
||||||
{
|
{
|
||||||
$this->items = $this->get('Items');
|
$this->items = $this->get('Items');
|
||||||
$this->pagination = $this->get('Pagination');
|
$this->pagination = $this->get('Pagination');
|
||||||
$this->state = $this->get('State');
|
$this->state = $this->get('State');
|
||||||
$this->filterForm = $this->get('FilterForm');
|
|
||||||
$this->activeFilters = $this->get('ActiveFilters');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
$this->addToolbar();
|
||||||
|
|
||||||
@@ -43,14 +37,5 @@ class HtmlView extends BaseHtmlView
|
|||||||
{
|
{
|
||||||
ToolbarHelper::title('MokoJoomCross — Activity Logs', 'share-alt');
|
ToolbarHelper::title('MokoJoomCross — Activity Logs', 'share-alt');
|
||||||
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE');
|
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE');
|
||||||
|
|
||||||
// Dashboard link in toolbar
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\View\Post;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
|
||||||
{
|
|
||||||
protected $form;
|
|
||||||
protected $item;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
|
||||||
{
|
|
||||||
$this->form = $this->get('Form');
|
|
||||||
$this->item = $this->get('Item');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
|
||||||
|
|
||||||
parent::display($tpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addToolbar(): void
|
|
||||||
{
|
|
||||||
$isNew = empty($this->item->id);
|
|
||||||
|
|
||||||
ToolbarHelper::title(
|
|
||||||
'MokoJoomCross — ' . ($isNew ? Text::_('COM_MOKOJOOMCROSS_NEW_POST') : Text::_('COM_MOKOJOOMCROSS_EDIT_POST')),
|
|
||||||
'share-alt'
|
|
||||||
);
|
|
||||||
|
|
||||||
ToolbarHelper::apply('post.apply');
|
|
||||||
ToolbarHelper::save('post.save');
|
|
||||||
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
|
|
||||||
ToolbarHelper::cancel('post.cancel');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,27 +14,19 @@ namespace Joomla\Component\MokoJoomCross\Administrator\View\Posts;
|
|||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\MokoJoomCrossHelper;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
{
|
{
|
||||||
protected $items;
|
protected $items;
|
||||||
protected $pagination;
|
protected $pagination;
|
||||||
protected $state;
|
protected $state;
|
||||||
public $filterForm;
|
|
||||||
public $activeFilters;
|
|
||||||
public $sidebar;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
public function display($tpl = null): void
|
||||||
{
|
{
|
||||||
$this->items = $this->get('Items');
|
$this->items = $this->get('Items');
|
||||||
$this->pagination = $this->get('Pagination');
|
$this->pagination = $this->get('Pagination');
|
||||||
$this->state = $this->get('State');
|
$this->state = $this->get('State');
|
||||||
$this->filterForm = $this->get('FilterForm');
|
|
||||||
$this->activeFilters = $this->get('ActiveFilters');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
$this->addToolbar();
|
||||||
|
|
||||||
@@ -44,39 +36,6 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected function addToolbar(): void
|
protected function addToolbar(): void
|
||||||
{
|
{
|
||||||
ToolbarHelper::title('MokoJoomCross — Post Queue', 'share-alt');
|
ToolbarHelper::title('MokoJoomCross — Post Queue', 'share-alt');
|
||||||
ToolbarHelper::addNew('post.add');
|
|
||||||
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->standardButton('retry', 'COM_MOKOJOOMCROSS_TOOLBAR_RETRY_FAILED', 'posts.retryFailed')
|
|
||||||
->icon('icon-refresh')
|
|
||||||
->listCheck(false);
|
|
||||||
$toolbar->standardButton('purge', 'COM_MOKOJOOMCROSS_TOOLBAR_PURGE_POSTED', 'posts.purgePosted')
|
|
||||||
->icon('icon-trash')
|
|
||||||
->listCheck(false);
|
|
||||||
|
|
||||||
$toolbar->standardButton('retry-selected', 'COM_MOKOJOOMCROSS_TOOLBAR_RETRY_SELECTED', 'posts.retrySelected')
|
|
||||||
->icon('icon-redo')
|
|
||||||
->listCheck(true);
|
|
||||||
$toolbar->standardButton('schedule', 'COM_MOKOJOOMCROSS_TOOLBAR_SCHEDULE', 'posts.schedule')
|
|
||||||
->icon('icon-calendar')
|
|
||||||
->listCheck(true);
|
|
||||||
|
|
||||||
ToolbarHelper::deleteList('', 'posts.delete', 'JTOOLBAR_DELETE');
|
ToolbarHelper::deleteList('', 'posts.delete', 'JTOOLBAR_DELETE');
|
||||||
|
|
||||||
// Export CSV button
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'download',
|
|
||||||
'COM_MOKOJOOMCROSS_EXPORT_CSV',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&task=posts.exportCsv&format=raw', false)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Dashboard link in toolbar
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\View\Service;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
|
||||||
{
|
|
||||||
protected $form;
|
|
||||||
protected $item;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
|
||||||
{
|
|
||||||
$this->form = $this->get('Form');
|
|
||||||
$this->item = $this->get('Item');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
|
||||||
|
|
||||||
parent::display($tpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addToolbar(): void
|
|
||||||
{
|
|
||||||
$isNew = empty($this->item->id);
|
|
||||||
|
|
||||||
ToolbarHelper::title(
|
|
||||||
'MokoJoomCross — ' . ($isNew ? Text::_('COM_MOKOJOOMCROSS_NEW_SERVICE') : Text::_('COM_MOKOJOOMCROSS_EDIT_SERVICE')),
|
|
||||||
'share-alt'
|
|
||||||
);
|
|
||||||
|
|
||||||
ToolbarHelper::apply('service.apply');
|
|
||||||
ToolbarHelper::save('service.save');
|
|
||||||
|
|
||||||
// Dashboard button in toolbar
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
|
|
||||||
ToolbarHelper::cancel('service.cancel');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<\!DOCTYPE html><title></title>
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\View\ServiceStats;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\MokoJoomCrossHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Per-service analytics drill-down view.
|
|
||||||
*/
|
|
||||||
class HtmlView extends BaseHtmlView
|
|
||||||
{
|
|
||||||
public $service;
|
|
||||||
public $postStats;
|
|
||||||
public $dailyTrend;
|
|
||||||
public $recentPosts;
|
|
||||||
public $topArticles;
|
|
||||||
public $period;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
|
||||||
{
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\Model\ServiceStatsModel $model */
|
|
||||||
$model = $this->getModel();
|
|
||||||
|
|
||||||
$serviceId = $model->getServiceId();
|
|
||||||
|
|
||||||
$this->service = $model->getService($serviceId);
|
|
||||||
|
|
||||||
if (!$this->service) {
|
|
||||||
throw new \RuntimeException('Service not found.', 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->period = Factory::getApplication()->input->getInt('period', 30);
|
|
||||||
$validPeriods = [7, 30, 90, 0];
|
|
||||||
|
|
||||||
if (!\in_array($this->period, $validPeriods, true)) {
|
|
||||||
$this->period = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
$days = $this->period ?: 365;
|
|
||||||
|
|
||||||
$this->postStats = $model->getPostStats($serviceId);
|
|
||||||
$this->dailyTrend = $model->getDailyTrend($serviceId, $days);
|
|
||||||
$this->recentPosts = $model->getRecentPosts($serviceId, 20);
|
|
||||||
$this->topArticles = $model->getTopArticles($serviceId, 10);
|
|
||||||
|
|
||||||
$this->addToolbar();
|
|
||||||
|
|
||||||
MokoJoomCrossHelper::addSubmenu('servicestats');
|
|
||||||
|
|
||||||
parent::display($tpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addToolbar(): void
|
|
||||||
{
|
|
||||||
ToolbarHelper::title(
|
|
||||||
'MokoJoomCross — ' . $this->escape($this->service->title),
|
|
||||||
'share-alt'
|
|
||||||
);
|
|
||||||
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,6 @@ namespace Joomla\Component\MokoJoomCross\Administrator\View\Services;
|
|||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
class HtmlView extends BaseHtmlView
|
||||||
@@ -23,16 +21,12 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected $items;
|
protected $items;
|
||||||
protected $pagination;
|
protected $pagination;
|
||||||
protected $state;
|
protected $state;
|
||||||
public $filterForm;
|
|
||||||
public $activeFilters;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
public function display($tpl = null): void
|
||||||
{
|
{
|
||||||
$this->items = $this->get('Items');
|
$this->items = $this->get('Items');
|
||||||
$this->pagination = $this->get('Pagination');
|
$this->pagination = $this->get('Pagination');
|
||||||
$this->state = $this->get('State');
|
$this->state = $this->get('State');
|
||||||
$this->filterForm = $this->get('FilterForm');
|
|
||||||
$this->activeFilters = $this->get('ActiveFilters');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
$this->addToolbar();
|
||||||
|
|
||||||
@@ -47,14 +41,5 @@ class HtmlView extends BaseHtmlView
|
|||||||
ToolbarHelper::publish('services.publish', 'JTOOLBAR_PUBLISH', true);
|
ToolbarHelper::publish('services.publish', 'JTOOLBAR_PUBLISH', true);
|
||||||
ToolbarHelper::unpublish('services.unpublish', 'JTOOLBAR_UNPUBLISH', true);
|
ToolbarHelper::unpublish('services.unpublish', 'JTOOLBAR_UNPUBLISH', true);
|
||||||
ToolbarHelper::deleteList('', 'services.delete', 'JTOOLBAR_DELETE');
|
ToolbarHelper::deleteList('', 'services.delete', 'JTOOLBAR_DELETE');
|
||||||
|
|
||||||
// Dashboard link in toolbar
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\View\Template;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
|
||||||
{
|
|
||||||
protected $form;
|
|
||||||
protected $item;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
|
||||||
{
|
|
||||||
$this->form = $this->get('Form');
|
|
||||||
$this->item = $this->get('Item');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
|
||||||
|
|
||||||
parent::display($tpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addToolbar(): void
|
|
||||||
{
|
|
||||||
$isNew = empty($this->item->id);
|
|
||||||
|
|
||||||
ToolbarHelper::title(
|
|
||||||
'MokoJoomCross — ' . ($isNew ? 'New Template' : 'Edit Template'),
|
|
||||||
'share-alt'
|
|
||||||
);
|
|
||||||
ToolbarHelper::apply('template.apply');
|
|
||||||
ToolbarHelper::save('template.save');
|
|
||||||
ToolbarHelper::cancel('template.cancel');
|
|
||||||
|
|
||||||
// Dashboard link in toolbar
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Component\MokoJoomCross\Administrator\View\Templates;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\CMS\Toolbar\Toolbar;
|
|
||||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView
|
|
||||||
{
|
|
||||||
protected $items;
|
|
||||||
protected $pagination;
|
|
||||||
protected $state;
|
|
||||||
public $filterForm;
|
|
||||||
public $activeFilters;
|
|
||||||
|
|
||||||
public function display($tpl = null): void
|
|
||||||
{
|
|
||||||
$this->items = $this->get('Items');
|
|
||||||
$this->pagination = $this->get('Pagination');
|
|
||||||
$this->state = $this->get('State');
|
|
||||||
$this->filterForm = $this->get('FilterForm');
|
|
||||||
$this->activeFilters = $this->get('ActiveFilters');
|
|
||||||
|
|
||||||
$this->addToolbar();
|
|
||||||
|
|
||||||
parent::display($tpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addToolbar(): void
|
|
||||||
{
|
|
||||||
ToolbarHelper::title('MokoJoomCross — Message Templates', 'share-alt');
|
|
||||||
ToolbarHelper::addNew('template.add');
|
|
||||||
ToolbarHelper::editList('template.edit');
|
|
||||||
ToolbarHelper::publish('templates.publish', 'JTOOLBAR_PUBLISH', true);
|
|
||||||
ToolbarHelper::unpublish('templates.unpublish', 'JTOOLBAR_UNPUBLISH', true);
|
|
||||||
ToolbarHelper::deleteList('', 'templates.delete', 'JTOOLBAR_DELETE');
|
|
||||||
|
|
||||||
// Dashboard link in toolbar
|
|
||||||
$toolbar = Toolbar::getInstance('toolbar');
|
|
||||||
$toolbar->appendButton(
|
|
||||||
'Link',
|
|
||||||
'home',
|
|
||||||
'COM_MOKOJOOMCROSS_SUBMENU_DASHBOARD',
|
|
||||||
Route::_('index.php?option=com_mokojoomcross&view=dashboard', false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -11,36 +11,12 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Component\ComponentHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
use Joomla\CMS\Language\Text;
|
||||||
use Joomla\CMS\Router\Route;
|
use Joomla\CMS\Router\Route;
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\ServiceIconHelper;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Dashboard\HtmlView $this */
|
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Dashboard\HtmlView $this */
|
||||||
$stats = $this->stats;
|
$stats = $this->stats;
|
||||||
$componentParams = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
$queueProcessing = $componentParams->get('queue_processing', 'scheduler');
|
|
||||||
?>
|
?>
|
||||||
<?php if ($queueProcessing === 'pageload' || $queueProcessing === 'both') : ?>
|
|
||||||
<div class="alert alert-warning d-flex align-items-start mb-3">
|
|
||||||
<span class="icon-exclamation-triangle me-2 mt-1" aria-hidden="true"></span>
|
|
||||||
<div>
|
|
||||||
<strong><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_PAGELOAD_WARNING_TITLE'); ?></strong><br>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_PAGELOAD_WARNING'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ($stats->queued_count > 50) : ?>
|
|
||||||
<div class="alert alert-warning d-flex align-items-start mb-3">
|
|
||||||
<span class="icon-exclamation-triangle me-2 mt-1" aria-hidden="true"></span>
|
|
||||||
<div>
|
|
||||||
<strong><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_QUEUE_DEPTH_WARNING_TITLE'); ?></strong><br>
|
|
||||||
<?php echo Text::sprintf('COM_MOKOJOOMCROSS_DASHBOARD_QUEUE_DEPTH_WARNING', $stats->queued_count); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-9">
|
<div class="col-lg-9">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -78,71 +54,6 @@ $queueProcessing = $componentParams->get('queue_processing', 'scheduler');
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Trend Chart -->
|
|
||||||
<?php if (!empty($this->dailyTrend)) : ?>
|
|
||||||
<div class="card mb-3">
|
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_TREND_CHART'); ?></h5>
|
|
||||||
<form method="get" class="d-inline">
|
|
||||||
<input type="hidden" name="option" value="com_mokojoomcross" />
|
|
||||||
<input type="hidden" name="view" value="dashboard" />
|
|
||||||
<select name="period" class="form-select form-select-sm" style="width: auto; display: inline-block;" onchange="this.form.submit();">
|
|
||||||
<option value="7" <?php echo $this->period == 7 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_7_DAYS'); ?></option>
|
|
||||||
<option value="30" <?php echo $this->period == 30 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_30_DAYS'); ?></option>
|
|
||||||
<option value="90" <?php echo $this->period == 90 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_90_DAYS'); ?></option>
|
|
||||||
<option value="0" <?php echo $this->period == 0 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_ALL_TIME'); ?></option>
|
|
||||||
</select>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<canvas id="trendChart" height="80"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js" integrity="sha384-UPIssOjNMqMfON6mDKHvO4sOY4hhxN1ymYcfl2MrDz69idMU/L3MNFlyJGlIRjQH" crossorigin="anonymous">
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
var trendData = <?php echo json_encode($this->dailyTrend); ?>;
|
|
||||||
var labels = trendData.map(function(d) { return d.day; });
|
|
||||||
var posted = trendData.map(function(d) { return parseInt(d.posted, 10); });
|
|
||||||
var failed = trendData.map(function(d) { return parseInt(d.failed, 10); });
|
|
||||||
|
|
||||||
new Chart(document.getElementById('trendChart'), {
|
|
||||||
type: 'line',
|
|
||||||
data: {
|
|
||||||
labels: labels,
|
|
||||||
datasets: [
|
|
||||||
{
|
|
||||||
label: '<?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_POSTED', true); ?>',
|
|
||||||
data: posted,
|
|
||||||
borderColor: '#198754',
|
|
||||||
backgroundColor: 'rgba(25, 135, 84, 0.1)',
|
|
||||||
fill: true,
|
|
||||||
tension: 0.3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '<?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_FAILED', true); ?>',
|
|
||||||
data: failed,
|
|
||||||
borderColor: '#dc3545',
|
|
||||||
backgroundColor: 'rgba(220, 53, 69, 0.1)',
|
|
||||||
fill: true,
|
|
||||||
tension: 0.3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
responsive: true,
|
|
||||||
scales: {
|
|
||||||
y: { beginAtZero: true, ticks: { stepSize: 1 } }
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
legend: { position: 'bottom' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ($this->migrationAvailable) : ?>
|
<?php if ($this->migrationAvailable) : ?>
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<h4 class="alert-heading"><?php echo Text::_('COM_MOKOJOOMCROSS_MIGRATION_TITLE'); ?></h4>
|
<h4 class="alert-heading"><?php echo Text::_('COM_MOKOJOOMCROSS_MIGRATION_TITLE'); ?></h4>
|
||||||
@@ -153,112 +64,6 @@ $queueProcessing = $componentParams->get('queue_processing', 'scheduler');
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- Analytics: Service Breakdown -->
|
|
||||||
<?php if (!empty($this->serviceBreakdown)) : ?>
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_SERVICE_BREAKDOWN'); ?></h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<table class="table table-sm table-striped mb-0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_SERVICE'); ?></th>
|
|
||||||
<th class="text-center text-success"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_POSTED'); ?></th>
|
|
||||||
<th class="text-center text-danger"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_FAILED'); ?></th>
|
|
||||||
<th class="text-center text-warning"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_QUEUED'); ?></th>
|
|
||||||
<th class="text-center"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_TOTAL_POSTS'); ?></th>
|
|
||||||
<th class="text-center"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_SUCCESS_RATE'); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->serviceBreakdown as $row) :
|
|
||||||
$rate = $row['total'] > 0 ? round(($row['posted'] / $row['total']) * 100) : 0;
|
|
||||||
$rateClass = $rate >= 80 ? 'text-success' : ($rate >= 50 ? 'text-warning' : 'text-danger');
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<?php echo ServiceIconHelper::renderIcon($row['service_type']); ?>
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&view=servicestats&id=' . $row['service_id']); ?>">
|
|
||||||
<?php echo htmlspecialchars($row['service_title'] . ' (' . ucfirst($row['service_type']) . ')'); ?>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="text-center"><span class="badge bg-success"><?php echo (int) $row['posted']; ?></span></td>
|
|
||||||
<td class="text-center"><span class="badge bg-danger"><?php echo (int) $row['failed']; ?></span></td>
|
|
||||||
<td class="text-center"><span class="badge bg-warning text-dark"><?php echo (int) $row['queued']; ?></span></td>
|
|
||||||
<td class="text-center"><?php echo (int) $row['total']; ?></td>
|
|
||||||
<td class="text-center <?php echo $rateClass; ?> fw-bold"><?php echo $rate; ?>%</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<!-- Analytics: Top Articles -->
|
|
||||||
<?php if (!empty($this->topArticles)) : ?>
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_TOP_ARTICLES'); ?></h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body p-0">
|
|
||||||
<div class="list-group list-group-flush">
|
|
||||||
<?php foreach ($this->topArticles as $row) : ?>
|
|
||||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
||||||
<span><?php echo htmlspecialchars($row['title']); ?></span>
|
|
||||||
<span>
|
|
||||||
<span class="badge bg-success"><?php echo (int) $row['success_count']; ?></span>
|
|
||||||
/
|
|
||||||
<span class="badge bg-secondary"><?php echo (int) $row['post_count']; ?></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<!-- Recent Activity -->
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_RECENT_ACTIVITY'); ?></h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body p-0">
|
|
||||||
<?php if (empty($this->recentActivity)) : ?>
|
|
||||||
<p class="p-3 mb-0 text-muted"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_NO_RECENT'); ?></p>
|
|
||||||
<?php else : ?>
|
|
||||||
<div class="list-group list-group-flush">
|
|
||||||
<?php foreach ($this->recentActivity as $entry) :
|
|
||||||
$levelClass = match ($entry->level) {
|
|
||||||
'error' => 'text-danger',
|
|
||||||
'warning' => 'text-warning',
|
|
||||||
default => 'text-muted',
|
|
||||||
};
|
|
||||||
$levelIcon = match ($entry->level) {
|
|
||||||
'error' => 'icon-times-circle',
|
|
||||||
'warning' => 'icon-exclamation-triangle',
|
|
||||||
default => 'icon-info-circle',
|
|
||||||
};
|
|
||||||
?>
|
|
||||||
<div class="list-group-item">
|
|
||||||
<div class="d-flex w-100 justify-content-between">
|
|
||||||
<span class="<?php echo $levelClass; ?>">
|
|
||||||
<span class="<?php echo $levelIcon; ?>" aria-hidden="true"></span>
|
|
||||||
<?php echo htmlspecialchars(mb_substr($entry->message, 0, 120)); ?>
|
|
||||||
</span>
|
|
||||||
<small class="text-muted"><?php echo \Joomla\CMS\HTML\HTMLHelper::_('date', $entry->created, 'Y-m-d H:i'); ?></small>
|
|
||||||
</div>
|
|
||||||
<?php if ($entry->service_title) : ?>
|
|
||||||
<small class="text-muted"><?php echo htmlspecialchars($entry->service_title); ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
@@ -274,10 +79,6 @@ $queueProcessing = $componentParams->get('queue_processing', 'scheduler');
|
|||||||
class="list-group-item list-group-item-action">
|
class="list-group-item list-group-item-action">
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_POSTS'); ?>
|
<?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_POSTS'); ?>
|
||||||
</a>
|
</a>
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&view=templates'); ?>"
|
|
||||||
class="list-group-item list-group-item-action">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_TEMPLATES'); ?>
|
|
||||||
</a>
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&view=logs'); ?>"
|
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&view=logs'); ?>"
|
||||||
class="list-group-item list-group-item-action">
|
class="list-group-item list-group-item-action">
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_LOGS'); ?>
|
<?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_LOGS'); ?>
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Layout\LayoutHelper;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Logs\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.multiselect');
|
|
||||||
|
|
||||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
|
||||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
|
||||||
|
|
||||||
$levelBadges = [
|
|
||||||
'info' => 'bg-info',
|
|
||||||
'warning' => 'bg-warning text-dark',
|
|
||||||
'error' => 'bg-danger',
|
|
||||||
];
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&view=logs'); ?>" method="post" name="adminForm" id="adminForm">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div id="j-main-container" class="j-main-container">
|
|
||||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
|
||||||
|
|
||||||
<?php if (empty($this->items)) : ?>
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
|
||||||
</div>
|
|
||||||
<?php else : ?>
|
|
||||||
<table class="table" id="logsList">
|
|
||||||
<caption class="visually-hidden"><?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_LOGS'); ?></caption>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td class="w-1 text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
|
||||||
</td>
|
|
||||||
<th scope="col" class="w-10">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_LEVEL'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_MESSAGE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-15 d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_SERVICE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-10">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_MOKOJOOMCROSS_HEADING_CREATED', 'a.created', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-5 text-center d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('JGRID_HEADING_ID'); ?>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->items as $i => $item) :
|
|
||||||
$badgeClass = $levelBadges[$item->level] ?? 'bg-secondary';
|
|
||||||
?>
|
|
||||||
<tr class="row<?php echo $i % 2; ?>">
|
|
||||||
<td class="text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', ''); ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="badge <?php echo $badgeClass; ?>">
|
|
||||||
<?php echo $this->escape(ucfirst($item->level)); ?>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo $this->escape($item->message); ?>
|
|
||||||
<?php if (!empty($item->context) && $item->context !== '{}') : ?>
|
|
||||||
<br><small class="text-muted"><code><?php echo $this->escape(mb_substr($item->context, 0, 200)); ?></code></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td class="d-none d-md-table-cell">
|
|
||||||
<?php echo $this->escape($item->service_title ?? '—'); ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo HTMLHelper::_('date', $item->created, 'Y-m-d H:i:s'); ?>
|
|
||||||
</td>
|
|
||||||
<td class="text-center d-none d-md-table-cell">
|
|
||||||
<?php echo (int) $item->id; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<?php echo $this->pagination->getListFooter(); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<input type="hidden" name="boxchecked" value="0">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Post\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.formvalidator');
|
|
||||||
HTMLHelper::_('behavior.keepalive');
|
|
||||||
|
|
||||||
$postId = (int) ($this->item->id ?? 0);
|
|
||||||
$isNew = empty($postId);
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&layout=edit&id=' . $postId); ?>"
|
|
||||||
method="post" name="adminForm" id="adminForm" class="form-validate">
|
|
||||||
|
|
||||||
<div class="main-card">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<h3><?php echo Text::_($isNew ? 'COM_MOKOJOOMCROSS_NEW_POST' : 'COM_MOKOJOOMCROSS_EDIT_POST'); ?></h3>
|
|
||||||
|
|
||||||
<?php if ($isNew) : ?>
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_POST_CREATE_HELP'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php echo $this->form->renderFieldset('details'); ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<?php if (!$isNew) : ?>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0">
|
|
||||||
<span class="icon-chart-bar" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_POST_RESULTS'); ?>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<?php echo $this->form->renderFieldset('readonly'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$status = $this->item->status ?? '';
|
|
||||||
if (in_array($status, ['failed', 'posted'])) : ?>
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-body text-center">
|
|
||||||
<p class="text-muted mb-2"><?php echo Text::_('COM_MOKOJOOMCROSS_POST_REQUEUE_HELP'); ?></p>
|
|
||||||
<button type="button" class="btn btn-warning w-100"
|
|
||||||
onclick="document.getElementById('jform_status').value='queued'; Joomla.submitbutton('post.apply');">
|
|
||||||
<span class="icon-refresh" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_POST_REQUEUE'); ?>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</form>
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Layout\LayoutHelper;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\ServiceIconHelper;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Posts\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.multiselect');
|
|
||||||
|
|
||||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
|
||||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
|
||||||
|
|
||||||
$statusBadges = [
|
|
||||||
'queued' => 'bg-warning text-dark',
|
|
||||||
'posting' => 'bg-info',
|
|
||||||
'posted' => 'bg-success',
|
|
||||||
'failed' => 'bg-danger',
|
|
||||||
'scheduled' => 'bg-secondary',
|
|
||||||
];
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&view=posts'); ?>" method="post" name="adminForm" id="adminForm">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div id="j-main-container" class="j-main-container">
|
|
||||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
|
||||||
|
|
||||||
<?php if (empty($this->items)) : ?>
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
|
||||||
</div>
|
|
||||||
<?php else : ?>
|
|
||||||
<table class="table" id="postsList">
|
|
||||||
<caption class="visually-hidden"><?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_POSTS'); ?></caption>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td class="w-1 text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
|
||||||
</td>
|
|
||||||
<th scope="col" class="w-10">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_STATUS'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_ARTICLE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-15">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_SERVICE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-15 d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_MESSAGE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_MOKOJOOMCROSS_HEADING_POSTED_AT', 'a.posted_at', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-10 d-none d-lg-table-cell">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_MOKOJOOMCROSS_HEADING_CREATED', 'a.created', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-5 text-center d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('JGRID_HEADING_ID'); ?>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->items as $i => $item) :
|
|
||||||
$badgeClass = $statusBadges[$item->status] ?? 'bg-secondary';
|
|
||||||
?>
|
|
||||||
<tr class="row<?php echo $i % 2; ?>">
|
|
||||||
<td class="text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->article_title ?? ''); ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="badge <?php echo $badgeClass; ?>">
|
|
||||||
<?php echo $this->escape(ucfirst($item->status)); ?>
|
|
||||||
</span>
|
|
||||||
<?php if ($item->status === 'failed' && !empty($item->error_message)) : ?>
|
|
||||||
<br><small class="text-danger"><?php echo $this->escape(mb_substr($item->error_message, 0, 80)); ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($item->retry_count > 0) : ?>
|
|
||||||
<br><small class="text-muted">Retries: <?php echo (int) $item->retry_count; ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&task=post.edit&id=' . (int) $item->id); ?>">
|
|
||||||
<?php echo $this->escape($item->article_title ?? 'Article #' . $item->article_id); ?>
|
|
||||||
</a>
|
|
||||||
<?php if (!empty($item->scheduled_at)) : ?>
|
|
||||||
<br><small class="text-info"><span class="icon-clock" aria-hidden="true"></span> <?php echo HTMLHelper::_('date', $item->scheduled_at, 'Y-m-d H:i'); ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo $this->escape($item->service_title ?? ''); ?>
|
|
||||||
<br><small class="text-muted"><?php echo ServiceIconHelper::renderIcon($item->service_type ?? ''); ?> <?php echo $this->escape($item->service_type ?? ''); ?></small>
|
|
||||||
</td>
|
|
||||||
<td class="d-none d-md-table-cell">
|
|
||||||
<small><?php echo $this->escape(mb_substr($item->message ?? '', 0, 100)); ?></small>
|
|
||||||
<?php if (!empty($item->platform_post_id)) : ?>
|
|
||||||
<br><small class="text-success">ID: <?php echo $this->escape($item->platform_post_id); ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td class="d-none d-md-table-cell">
|
|
||||||
<?php echo $item->posted_at ? HTMLHelper::_('date', $item->posted_at, 'Y-m-d H:i') : '—'; ?>
|
|
||||||
</td>
|
|
||||||
<td class="d-none d-lg-table-cell">
|
|
||||||
<?php echo HTMLHelper::_('date', $item->created, 'Y-m-d H:i'); ?>
|
|
||||||
</td>
|
|
||||||
<td class="text-center d-none d-md-table-cell">
|
|
||||||
<?php echo (int) $item->id; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<?php echo $this->pagination->getListFooter(); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<input type="hidden" name="boxchecked" value="0">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Service\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.formvalidator');
|
|
||||||
HTMLHelper::_('behavior.keepalive');
|
|
||||||
|
|
||||||
$serviceType = $this->item->service_type ?? '';
|
|
||||||
$serviceId = (int) ($this->item->id ?? 0);
|
|
||||||
|
|
||||||
// Services that support OAuth authorize flow
|
|
||||||
$oauthServices = ['facebook', 'linkedin', 'twitter', 'threads', 'pinterest', 'tumblr', 'tiktok', 'constantcontact', 'blogger', 'googlebusiness'];
|
|
||||||
$showAuthorize = in_array($serviceType, $oauthServices) && $serviceId > 0;
|
|
||||||
|
|
||||||
// Map service types to KB article aliases on mokoconsulting.tech
|
|
||||||
$helpArticles = [
|
|
||||||
'facebook' => 'service-facebook-mokojoomcross',
|
|
||||||
'twitter' => 'service-twitter-mokojoomcross',
|
|
||||||
'linkedin' => 'service-linkedin-mokojoomcross',
|
|
||||||
'mastodon' => 'service-mastodon-mokojoomcross',
|
|
||||||
'bluesky' => 'service-bluesky-mokojoomcross',
|
|
||||||
'threads' => 'service-threads-mokojoomcross',
|
|
||||||
'pinterest' => 'service-pinterest-mokojoomcross',
|
|
||||||
'reddit' => 'service-reddit-mokojoomcross',
|
|
||||||
'tumblr' => 'service-tumblr-mokojoomcross',
|
|
||||||
'tiktok' => 'service-tiktok-mokojoomcross',
|
|
||||||
'nostr' => 'service-nostr-mokojoomcross',
|
|
||||||
'activitypub' => 'service-activitypub-mokojoomcross',
|
|
||||||
'telegram' => 'service-telegram-mokojoomcross',
|
|
||||||
'discord' => 'service-discord-mokojoomcross',
|
|
||||||
'slack' => 'service-slack-mokojoomcross',
|
|
||||||
'teams' => 'service-teams-mokojoomcross',
|
|
||||||
'googlechat' => 'service-googlechat-mokojoomcross',
|
|
||||||
'whatsapp' => 'service-whatsapp-mokojoomcross',
|
|
||||||
'matrix' => 'service-matrix-mokojoomcross',
|
|
||||||
'ntfy' => 'service-ntfy-mokojoomcross',
|
|
||||||
'mailchimp' => 'service-mailchimp-mokojoomcross',
|
|
||||||
'sendgrid' => 'service-sendgrid-mokojoomcross',
|
|
||||||
'brevo' => 'service-brevo-mokojoomcross',
|
|
||||||
'convertkit' => 'service-convertkit-mokojoomcross',
|
|
||||||
'constantcontact' => 'service-constantcontact-mokojoomcross',
|
|
||||||
'medium' => 'service-medium-mokojoomcross',
|
|
||||||
'wordpress' => 'service-wordpress-mokojoomcross',
|
|
||||||
'devto' => 'service-devto-mokojoomcross',
|
|
||||||
'ghost' => 'service-ghost-mokojoomcross',
|
|
||||||
'hashnode' => 'service-hashnode-mokojoomcross',
|
|
||||||
'blogger' => 'service-blogger-mokojoomcross',
|
|
||||||
'googlebusiness' => 'service-googlebusiness-mokojoomcross',
|
|
||||||
'webhook' => 'service-webhook-mokojoomcross',
|
|
||||||
'rssfeed' => 'service-rssfeed-mokojoomcross',
|
|
||||||
];
|
|
||||||
$helpAlias = $helpArticles[$serviceType] ?? '';
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&layout=edit&id=' . $serviceId); ?>"
|
|
||||||
method="post" name="adminForm" id="adminForm" class="form-validate">
|
|
||||||
|
|
||||||
<div class="main-card">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<h3><?php echo Text::_('COM_MOKOJOOMCROSS_SERVICE_DETAILS'); ?></h3>
|
|
||||||
<?php echo $this->form->renderFieldset('details'); ?>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h3><?php echo Text::_('COM_MOKOJOOMCROSS_FIELDSET_CREDENTIALS'); ?></h3>
|
|
||||||
<p class="text-muted">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_CREDENTIALS_HELP'); ?>
|
|
||||||
</p>
|
|
||||||
<?php echo $this->form->renderFieldset('credentials'); ?>
|
|
||||||
|
|
||||||
<?php if ($showAuthorize) : ?>
|
|
||||||
<div class="mt-3">
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&task=oauth.authorize&service_id=' . $serviceId); ?>"
|
|
||||||
class="btn btn-primary btn-lg">
|
|
||||||
<span class="icon-key" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::sprintf('COM_MOKOJOOMCROSS_AUTHORIZE_BUTTON', ucfirst($serviceType)); ?>
|
|
||||||
</a>
|
|
||||||
<p class="form-text mt-2">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_AUTHORIZE_HELP'); ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header bg-info text-white">
|
|
||||||
<h5 class="card-title mb-0">
|
|
||||||
<span class="icon-question-circle" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_SETUP_HELP_TITLE'); ?>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p><?php echo Text::_('COM_MOKOJOOMCROSS_SETUP_HELP_INTRO'); ?></p>
|
|
||||||
<ol class="mb-0">
|
|
||||||
<li><?php echo Text::_('COM_MOKOJOOMCROSS_SETUP_STEP1'); ?></li>
|
|
||||||
<li><?php echo Text::_('COM_MOKOJOOMCROSS_SETUP_STEP2'); ?></li>
|
|
||||||
<li><?php echo Text::_('COM_MOKOJOOMCROSS_SETUP_STEP3'); ?></li>
|
|
||||||
<li><?php echo Text::_('COM_MOKOJOOMCROSS_SETUP_STEP4'); ?></li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if (!empty($helpAlias)) : ?>
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-body text-center">
|
|
||||||
<a href="https://mokoconsulting.tech/kb/mokojoomcross/<?php echo $helpAlias; ?>"
|
|
||||||
target="_blank" rel="noopener"
|
|
||||||
class="btn btn-outline-info w-100">
|
|
||||||
<span class="icon-book" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::sprintf('COM_MOKOJOOMCROSS_SERVICE_HELP_LINK', ucfirst($serviceType)); ?>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ($showAuthorize) : ?>
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header bg-warning text-dark">
|
|
||||||
<h5 class="card-title mb-0">
|
|
||||||
<span class="icon-lock" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_OAUTH_HELP_TITLE'); ?>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p><?php echo Text::_('COM_MOKOJOOMCROSS_OAUTH_HELP_BODY'); ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ($serviceId > 0 && !empty($serviceType)) : ?>
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header bg-secondary text-white">
|
|
||||||
<h5 class="card-title mb-0">
|
|
||||||
<span class="icon-plug" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_TITLE'); ?>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p><?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_DESC'); ?></p>
|
|
||||||
<button type="button" id="btn-test-connection" class="btn btn-outline-primary w-100">
|
|
||||||
<span class="icon-broadcast" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_BUTTON'); ?>
|
|
||||||
</button>
|
|
||||||
<div id="test-connection-result" class="mt-2" style="display:none;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
document.getElementById('btn-test-connection').addEventListener('click', function() {
|
|
||||||
var btn = this;
|
|
||||||
var resultDiv = document.getElementById('test-connection-result');
|
|
||||||
btn.disabled = true;
|
|
||||||
btn.textContent = '<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_TESTING'); ?>';
|
|
||||||
resultDiv.style.display = 'none';
|
|
||||||
|
|
||||||
var url = 'index.php?option=com_mokojoomcross&task=service.testConnection&id=<?php echo $serviceId; ?>&format=json';
|
|
||||||
|
|
||||||
fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-Token': Joomla.getOptions('csrf.token') || '1'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(function(response) { return response.json(); })
|
|
||||||
.then(function(json) {
|
|
||||||
resultDiv.style.display = 'block';
|
|
||||||
resultDiv.textContent = '';
|
|
||||||
|
|
||||||
if (json.success) {
|
|
||||||
var data = json.data || {};
|
|
||||||
var accountName = data.account_name || '';
|
|
||||||
var msg = '<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_SUCCESS'); ?>';
|
|
||||||
if (accountName) {
|
|
||||||
msg += ' \u2014 ' + accountName;
|
|
||||||
}
|
|
||||||
resultDiv.className = 'mt-2 alert alert-success';
|
|
||||||
resultDiv.textContent = msg;
|
|
||||||
} else {
|
|
||||||
resultDiv.className = 'mt-2 alert alert-danger';
|
|
||||||
resultDiv.textContent = json.message || '<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_FAILED'); ?>';
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function() {
|
|
||||||
resultDiv.style.display = 'block';
|
|
||||||
resultDiv.className = 'mt-2 alert alert-danger';
|
|
||||||
resultDiv.textContent = '<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_ERROR'); ?>';
|
|
||||||
})
|
|
||||||
.finally(function() {
|
|
||||||
btn.disabled = false;
|
|
||||||
btn.textContent = '<?php echo Text::_('COM_MOKOJOOMCROSS_TEST_CONNECTION_BUTTON'); ?>';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</form>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<\!DOCTYPE html><title></title>
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Layout\LayoutHelper;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\ServiceIconHelper;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Services\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.multiselect');
|
|
||||||
|
|
||||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
|
||||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
|
||||||
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&view=services'); ?>" method="post" name="adminForm" id="adminForm">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div id="j-main-container" class="j-main-container">
|
|
||||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
|
||||||
|
|
||||||
<?php if (empty($this->items)) : ?>
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
|
||||||
</div>
|
|
||||||
<?php else : ?>
|
|
||||||
<table class="table" id="servicesList">
|
|
||||||
<caption class="visually-hidden"><?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_SERVICES'); ?></caption>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td class="w-1 text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
|
||||||
</td>
|
|
||||||
<th scope="col" class="w-1 text-center">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-15">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_MOKOJOOMCROSS_FIELD_SERVICE_TYPE', 'a.service_type', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-10 text-center d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_MODE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-5 text-center d-none d-md-table-cell">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->items as $i => $item) :
|
|
||||||
$credentials = json_decode($item->credentials ?: '{}', true) ?: [];
|
|
||||||
$mode = $credentials['mode'] ?? 'custom';
|
|
||||||
?>
|
|
||||||
<tr class="row<?php echo $i % 2; ?>">
|
|
||||||
<td class="text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?>
|
|
||||||
</td>
|
|
||||||
<td class="text-center">
|
|
||||||
<?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'services.', true); ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&task=service.edit&id=' . $item->id); ?>">
|
|
||||||
<?php echo $this->escape($item->title); ?>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo ServiceIconHelper::renderIcon($item->service_type); ?>
|
|
||||||
<?php echo $this->escape(ucfirst($item->service_type)); ?>
|
|
||||||
</td>
|
|
||||||
<td class="text-center d-none d-md-table-cell">
|
|
||||||
<?php if ($mode === 'default') : ?>
|
|
||||||
<span class="badge bg-primary">Default Bot</span>
|
|
||||||
<?php else : ?>
|
|
||||||
<span class="badge bg-secondary">Custom</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td class="text-center d-none d-md-table-cell">
|
|
||||||
<?php echo (int) $item->id; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<?php echo $this->pagination->getListFooter(); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<input type="hidden" name="boxchecked" value="0">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
/** @var \Joomla\CMS\Form\Form $this->form */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.formvalidator');
|
|
||||||
HTMLHelper::_('behavior.keepalive');
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&layout=edit&id=' . (int) $this->item->id); ?>"
|
|
||||||
method="post" name="adminForm" id="adminForm" class="form-validate">
|
|
||||||
|
|
||||||
<div class="main-card">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-9">
|
|
||||||
<?php echo $this->form->renderFieldset('details'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-3">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h4><?php echo Text::_('COM_MOKOJOOMCROSS_FIELDSET_CREDENTIALS'); ?></h4>
|
|
||||||
<?php echo $this->form->renderFieldset('credentials'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</form>
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\ServiceIconHelper;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\ServiceStats\HtmlView $this */
|
|
||||||
|
|
||||||
$service = $this->service;
|
|
||||||
$stats = $this->postStats;
|
|
||||||
$rate = $stats->total > 0 ? round(($stats->posted / $stats->total) * 100) : 0;
|
|
||||||
$rateClass = $rate >= 80 ? 'text-success' : ($rate >= 50 ? 'text-warning' : 'text-danger');
|
|
||||||
|
|
||||||
$statusBadges = [
|
|
||||||
'queued' => 'bg-warning text-dark',
|
|
||||||
'posting' => 'bg-info',
|
|
||||||
'posted' => 'bg-success',
|
|
||||||
'failed' => 'bg-danger',
|
|
||||||
'scheduled' => 'bg-secondary',
|
|
||||||
];
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Service Header -->
|
|
||||||
<div class="d-flex align-items-center mb-4">
|
|
||||||
<?php echo ServiceIconHelper::renderIcon($service->service_type, 'fs-3 me-2'); ?>
|
|
||||||
<h2 class="mb-0"><?php echo $this->escape($service->title); ?></h2>
|
|
||||||
<span class="badge bg-secondary ms-2"><?php echo $this->escape(ucfirst($service->service_type)); ?></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Stats Cards -->
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6 col-md-3">
|
|
||||||
<div class="card text-center mb-3">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_TOTAL_POSTS'); ?></h5>
|
|
||||||
<p class="display-4"><?php echo $stats->total; ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-3">
|
|
||||||
<div class="card text-center mb-3">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_POSTED'); ?></h5>
|
|
||||||
<p class="display-4 text-success"><?php echo $stats->posted; ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-3">
|
|
||||||
<div class="card text-center mb-3">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_FAILED'); ?></h5>
|
|
||||||
<p class="display-4 text-danger"><?php echo $stats->failed; ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-3">
|
|
||||||
<div class="card text-center mb-3">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_SUCCESS_RATE'); ?></h5>
|
|
||||||
<p class="display-4 <?php echo $rateClass; ?>"><?php echo $rate; ?>%</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Daily Trend Chart -->
|
|
||||||
<?php if (!empty($this->dailyTrend)) : ?>
|
|
||||||
<div class="card mb-3">
|
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_TREND_CHART'); ?></h5>
|
|
||||||
<form method="get" class="d-inline">
|
|
||||||
<input type="hidden" name="option" value="com_mokojoomcross" />
|
|
||||||
<input type="hidden" name="view" value="servicestats" />
|
|
||||||
<input type="hidden" name="id" value="<?php echo (int) $service->id; ?>" />
|
|
||||||
<select name="period" class="form-select form-select-sm" style="width: auto; display: inline-block;" onchange="this.form.submit();">
|
|
||||||
<option value="7" <?php echo $this->period == 7 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_7_DAYS'); ?></option>
|
|
||||||
<option value="30" <?php echo $this->period == 30 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_30_DAYS'); ?></option>
|
|
||||||
<option value="90" <?php echo $this->period == 90 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_90_DAYS'); ?></option>
|
|
||||||
<option value="0" <?php echo $this->period == 0 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOJOOMCROSS_PERIOD_ALL_TIME'); ?></option>
|
|
||||||
</select>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<canvas id="serviceStatsChart" height="80"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js" integrity="sha384-UPIssOjNMqMfON6mDKHvO4sOY4hhxN1ymYcfl2MrDz69idMU/L3MNFlyJGlIRjQH" crossorigin="anonymous"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
var trendData = <?php echo json_encode($this->dailyTrend); ?>;
|
|
||||||
var labels = trendData.map(function(d) { return d.day; });
|
|
||||||
var posted = trendData.map(function(d) { return parseInt(d.posted, 10); });
|
|
||||||
var failed = trendData.map(function(d) { return parseInt(d.failed, 10); });
|
|
||||||
|
|
||||||
new Chart(document.getElementById('serviceStatsChart'), {
|
|
||||||
type: 'line',
|
|
||||||
data: {
|
|
||||||
labels: labels,
|
|
||||||
datasets: [
|
|
||||||
{
|
|
||||||
label: '<?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_POSTED', true); ?>',
|
|
||||||
data: posted,
|
|
||||||
borderColor: '#198754',
|
|
||||||
backgroundColor: 'rgba(25, 135, 84, 0.1)',
|
|
||||||
fill: true,
|
|
||||||
tension: 0.3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '<?php echo Text::_('COM_MOKOJOOMCROSS_DASHBOARD_FAILED', true); ?>',
|
|
||||||
data: failed,
|
|
||||||
borderColor: '#dc3545',
|
|
||||||
backgroundColor: 'rgba(220, 53, 69, 0.1)',
|
|
||||||
fill: true,
|
|
||||||
tension: 0.3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
responsive: true,
|
|
||||||
scales: {
|
|
||||||
y: { beginAtZero: true, ticks: { stepSize: 1 } }
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
legend: { position: 'bottom' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<!-- Recent Posts -->
|
|
||||||
<div class="card mb-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_SERVICESTATS_RECENT_POSTS'); ?></h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body p-0">
|
|
||||||
<?php if (empty($this->recentPosts)) : ?>
|
|
||||||
<p class="p-3 mb-0 text-muted"><?php echo Text::_('COM_MOKOJOOMCROSS_SERVICESTATS_NO_POSTS'); ?></p>
|
|
||||||
<?php else : ?>
|
|
||||||
<table class="table table-sm table-striped mb-0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_STATUS'); ?></th>
|
|
||||||
<th><?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_ARTICLE'); ?></th>
|
|
||||||
<th><?php echo Text::_('COM_MOKOJOOMCROSS_HEADING_POSTED_AT'); ?></th>
|
|
||||||
<th><?php echo Text::_('COM_MOKOJOOMCROSS_POST_ERROR'); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->recentPosts as $post) :
|
|
||||||
$badgeClass = $statusBadges[$post['status']] ?? 'bg-secondary';
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<span class="badge <?php echo $badgeClass; ?>">
|
|
||||||
<?php echo $this->escape(ucfirst($post['status'])); ?>
|
|
||||||
</span>
|
|
||||||
<?php if ((int) $post['retry_count'] > 0) : ?>
|
|
||||||
<br><small class="text-muted">Retries: <?php echo (int) $post['retry_count']; ?></small>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&task=post.edit&id=' . (int) $post['id']); ?>">
|
|
||||||
<?php echo $this->escape($post['article_title'] ?? 'Article #' . $post['id']); ?>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo $post['posted_at'] ? HTMLHelper::_('date', $post['posted_at'], 'Y-m-d H:i') : '—'; ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php if (!empty($post['error_message'])) : ?>
|
|
||||||
<small class="text-danger"><?php echo $this->escape(mb_substr($post['error_message'], 0, 100)); ?></small>
|
|
||||||
<?php else : ?>
|
|
||||||
—
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Top Articles -->
|
|
||||||
<?php if (!empty($this->topArticles)) : ?>
|
|
||||||
<div class="card mb-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_SERVICESTATS_TOP_ARTICLES'); ?></h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body p-0">
|
|
||||||
<div class="list-group list-group-flush">
|
|
||||||
<?php foreach ($this->topArticles as $row) : ?>
|
|
||||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
||||||
<span><?php echo htmlspecialchars($row['title']); ?></span>
|
|
||||||
<span>
|
|
||||||
<span class="badge bg-success"><?php echo (int) $row['success_count']; ?></span>
|
|
||||||
/
|
|
||||||
<span class="badge bg-secondary"><?php echo (int) $row['post_count']; ?></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Template\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.formvalidator');
|
|
||||||
HTMLHelper::_('behavior.keepalive');
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&layout=edit&id=' . (int) ($this->item->id ?? 0)); ?>"
|
|
||||||
method="post" name="adminForm" id="adminForm" class="form-validate">
|
|
||||||
|
|
||||||
<div class="main-card">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<?php echo $this->form->renderFieldset('details'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOJOOMCROSS_TEMPLATE_PLACEHOLDERS'); ?></h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<table class="table table-sm table-striped">
|
|
||||||
<tbody>
|
|
||||||
<tr><td><code>{title}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_TITLE'); ?></td></tr>
|
|
||||||
<tr><td><code>{url}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_URL'); ?></td></tr>
|
|
||||||
<tr><td><code>{introtext}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_INTROTEXT'); ?></td></tr>
|
|
||||||
<tr><td><code>{fulltext}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_FULLTEXT'); ?></td></tr>
|
|
||||||
<tr><td><code>{image}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_IMAGE'); ?></td></tr>
|
|
||||||
<tr><td><code>{category}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_CATEGORY'); ?></td></tr>
|
|
||||||
<tr><td><code>{author}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_AUTHOR'); ?></td></tr>
|
|
||||||
<tr><td><code>{date}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_DATE'); ?></td></tr>
|
|
||||||
<tr><td><code>{tags}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_TAGS'); ?></td></tr>
|
|
||||||
<tr><td><code>{hashtags}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_HASHTAGS'); ?></td></tr>
|
|
||||||
<tr><td><code>{field:xxx}</code></td><td><?php echo Text::_('COM_MOKOJOOMCROSS_PLACEHOLDER_CUSTOM_FIELD'); ?></td></tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
const platformLimits = {
|
|
||||||
twitter: 280, bluesky: 300, mastodon: 500, threads: 500,
|
|
||||||
telegram: 4096, discord: 2000, whatsapp: 4096,
|
|
||||||
linkedin: 3000, googlebusiness: 1500, matrix: 65536,
|
|
||||||
ntfy: 4096, facebook: 0, medium: 0, wordpress: 0,
|
|
||||||
ghost: 0, hashnode: 0, blogger: 0, devto: 0,
|
|
||||||
default: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
const textarea = document.getElementById('jform_template_body');
|
|
||||||
const serviceSelect = document.getElementById('jform_service_type');
|
|
||||||
|
|
||||||
if (!textarea) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create counter element
|
|
||||||
const counter = document.createElement('div');
|
|
||||||
counter.id = 'mokojoomcross-char-counter';
|
|
||||||
counter.className = 'small mt-1';
|
|
||||||
textarea.parentNode.appendChild(counter);
|
|
||||||
|
|
||||||
function updateCounter() {
|
|
||||||
const len = textarea.value.length;
|
|
||||||
const serviceType = serviceSelect ? serviceSelect.value : 'default';
|
|
||||||
const limit = platformLimits[serviceType] || 0;
|
|
||||||
|
|
||||||
if (limit > 0) {
|
|
||||||
const ratio = len / limit;
|
|
||||||
let badgeClass = 'bg-success';
|
|
||||||
if (ratio > 1) {
|
|
||||||
badgeClass = 'bg-danger';
|
|
||||||
} else if (ratio > 0.9) {
|
|
||||||
badgeClass = 'bg-warning text-dark';
|
|
||||||
}
|
|
||||||
counter.innerHTML = '<span class="badge ' + badgeClass + '">Characters: ' + len + ' / ' + limit + '</span>';
|
|
||||||
} else {
|
|
||||||
counter.innerHTML = '<span class="badge bg-secondary">Characters: ' + len + ' (no limit)</span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea.addEventListener('input', updateCounter);
|
|
||||||
|
|
||||||
if (serviceSelect) {
|
|
||||||
serviceSelect.addEventListener('change', updateCounter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initial count
|
|
||||||
updateCounter();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage com_mokojoomcross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Language\Text;
|
|
||||||
use Joomla\CMS\Layout\LayoutHelper;
|
|
||||||
use Joomla\CMS\Router\Route;
|
|
||||||
|
|
||||||
/** @var \Joomla\Component\MokoJoomCross\Administrator\View\Templates\HtmlView $this */
|
|
||||||
|
|
||||||
HTMLHelper::_('behavior.multiselect');
|
|
||||||
|
|
||||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
|
||||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
|
||||||
?>
|
|
||||||
<form action="<?php echo Route::_('index.php?option=com_mokojoomcross&view=templates'); ?>" method="post" name="adminForm" id="adminForm">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div id="j-main-container" class="j-main-container">
|
|
||||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
|
||||||
|
|
||||||
<?php if (empty($this->items)) : ?>
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<span class="icon-info-circle" aria-hidden="true"></span>
|
|
||||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
|
||||||
</div>
|
|
||||||
<?php else : ?>
|
|
||||||
<table class="table" id="templatesList">
|
|
||||||
<caption class="visually-hidden"><?php echo Text::_('COM_MOKOJOOMCROSS_SUBMENU_TEMPLATES'); ?></caption>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td class="w-1 text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
|
||||||
</td>
|
|
||||||
<th scope="col" class="w-1 text-center">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col">
|
|
||||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-15">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_FIELD_SERVICE_TYPE'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('COM_MOKOJOOMCROSS_TEMPLATE_PREVIEW'); ?>
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="w-5 text-center d-none d-md-table-cell">
|
|
||||||
<?php echo Text::_('JGRID_HEADING_ID'); ?>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->items as $i => $item) : ?>
|
|
||||||
<tr class="row<?php echo $i % 2; ?>">
|
|
||||||
<td class="text-center">
|
|
||||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?>
|
|
||||||
</td>
|
|
||||||
<td class="text-center">
|
|
||||||
<?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'templates.', true); ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo Route::_('index.php?option=com_mokojoomcross&task=template.edit&id=' . $item->id); ?>">
|
|
||||||
<?php echo $this->escape($item->title); ?>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php if ($item->service_type === 'default') : ?>
|
|
||||||
<span class="badge bg-primary">Default</span>
|
|
||||||
<?php else : ?>
|
|
||||||
<?php echo $this->escape(ucfirst($item->service_type)); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
<td class="d-none d-md-table-cell">
|
|
||||||
<code class="small"><?php echo $this->escape(mb_substr($item->template_body, 0, 80)); ?></code>
|
|
||||||
</td>
|
|
||||||
<td class="text-center d-none d-md-table-cell">
|
|
||||||
<?php echo (int) $item->id; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<?php echo $this->pagination->getListFooter(); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<input type="hidden" name="task" value="">
|
|
||||||
<input type="hidden" name="boxchecked" value="0">
|
|
||||||
<?php echo HTMLHelper::_('form.token'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
+1
-12
@@ -1,13 +1,2 @@
|
|||||||
PLG_CONTENT_MOKOJOOMCROSS="Content - MokoJoomCross"
|
PLG_CONTENT_MOKOJOOMCROSS="Content - MokoJoomCross"
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_DESCRIPTION="Adds cross-post status badges and per-article service selection to the article editor."
|
PLG_CONTENT_MOKOJOOMCROSS_DESCRIPTION="Adds cross-post status badges to articles in the admin backend."
|
||||||
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_FIELDSET_CROSSPOST="Cross-Posting"
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_SKIP="Skip Cross-Posting"
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_SKIP_DESC="Skip all cross-posting for this article."
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_SERVICES="Post to Services"
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_SERVICES_DESC="Select which services to cross-post to. Leave all unchecked to post to all enabled services."
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN="Evergreen Content"
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN_DESC="Automatically re-share this article on a recurring schedule. Great for high-value content that stays relevant."
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN_INTERVAL="Re-share Interval (days)"
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN_INTERVAL_DESC="How many days to wait between automatic re-shares. Default: 30 days."
|
|
||||||
PLG_CONTENT_MOKOJOOMCROSS_HISTORY="Cross-Post History"
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="content" method="upgrade">
|
<extension type="plugin" group="content" method="upgrade">
|
||||||
<name>Content - MokoJoomCross</name>
|
<name>Content - MokoJoomCross</name>
|
||||||
<version>01.00.26-dev</version>
|
<version>01.00.00-dev</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
|
|||||||
@@ -13,214 +13,34 @@ namespace Joomla\Plugin\Content\MokoJoomCross\Extension;
|
|||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
use Joomla\CMS\Component\ComponentHelper;
|
|
||||||
use Joomla\CMS\Event\Model\PrepareFormEvent;
|
|
||||||
use Joomla\CMS\Factory;
|
use Joomla\CMS\Factory;
|
||||||
use Joomla\CMS\Form\Form;
|
|
||||||
use Joomla\CMS\HTML\HTMLHelper;
|
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
use Joomla\CMS\Plugin\CMSPlugin;
|
||||||
use Joomla\CMS\Uri\Uri;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Helper\CrossPostDispatcher;
|
|
||||||
use Joomla\Event\SubscriberInterface;
|
use Joomla\Event\SubscriberInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content plugin that:
|
* Content plugin that adds cross-post status badges to article views.
|
||||||
* 1. Adds cross-post status badges to article views in admin
|
|
||||||
* 2. Injects service selection checkboxes into the article editor (#19)
|
|
||||||
*/
|
*/
|
||||||
class MokoJoomCrossContent extends CMSPlugin implements SubscriberInterface
|
class MokoJoomCrossContent extends CMSPlugin implements SubscriberInterface
|
||||||
{
|
{
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'onContentBeforeDisplay' => 'onContentBeforeDisplay',
|
'onContentBeforeDisplay' => 'onContentBeforeDisplay',
|
||||||
'onContentPrepareForm' => 'onContentPrepareForm',
|
|
||||||
'onContentAfterSave' => 'onContentAfterSave',
|
|
||||||
'onContentChangeState' => 'onContentChangeState',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject cross-post service selection fields into article edit form.
|
* Add cross-post status indicator before article content in admin.
|
||||||
*
|
*
|
||||||
* Adds a "Cross-Posting" fieldset to the article attribs tab with:
|
* @param string $context The context
|
||||||
* - Checkbox list of all enabled services
|
* @param object $article The article
|
||||||
* - Skip cross-posting toggle
|
* @param object $params The article params
|
||||||
*/
|
* @param int $page The page number
|
||||||
/**
|
|
||||||
* Joomla 5/6 compatible — accepts both PrepareFormEvent and legacy Form signature.
|
|
||||||
*/
|
|
||||||
public function onContentPrepareForm($event): void
|
|
||||||
{
|
|
||||||
// Joomla 5+ passes PrepareFormEvent; extract the Form from it
|
|
||||||
if ($event instanceof PrepareFormEvent) {
|
|
||||||
$form = $event->getForm();
|
|
||||||
} elseif ($event instanceof Form) {
|
|
||||||
$form = $event;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($form->getName() !== 'com_content.article') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$app = $this->getApplication();
|
|
||||||
|
|
||||||
if (!$app->isClient('administrator')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
// Load enabled services for the checkbox list
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('id, title, service_type')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_services'))
|
|
||||||
->where($db->quoteName('published') . ' = 1')
|
|
||||||
->order($db->quoteName('ordering') . ' ASC');
|
|
||||||
|
|
||||||
$db->setQuery($query);
|
|
||||||
$services = $db->loadObjectList();
|
|
||||||
|
|
||||||
if (empty($services)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build dynamic XML form for the attribs fieldset
|
|
||||||
$options = '';
|
|
||||||
|
|
||||||
foreach ($services as $svc) {
|
|
||||||
$label = htmlspecialchars($svc->title . ' (' . ucfirst($svc->service_type) . ')', ENT_XML1);
|
|
||||||
$options .= '<option value="' . (int) $svc->id . '">' . $label . '</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$xml = <<<XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<form>
|
|
||||||
<fields name="attribs">
|
|
||||||
<fieldset name="mokojoomcross" label="PLG_CONTENT_MOKOJOOMCROSS_FIELDSET_CROSSPOST">
|
|
||||||
<field
|
|
||||||
name="mokojoomcross_skip"
|
|
||||||
type="radio"
|
|
||||||
label="PLG_CONTENT_MOKOJOOMCROSS_SKIP"
|
|
||||||
description="PLG_CONTENT_MOKOJOOMCROSS_SKIP_DESC"
|
|
||||||
default="0"
|
|
||||||
class="btn-group btn-group-yesno">
|
|
||||||
<option value="0">JNO</option>
|
|
||||||
<option value="1">JYES</option>
|
|
||||||
</field>
|
|
||||||
<field
|
|
||||||
name="mokojoomcross_services"
|
|
||||||
type="checkboxes"
|
|
||||||
label="PLG_CONTENT_MOKOJOOMCROSS_SERVICES"
|
|
||||||
description="PLG_CONTENT_MOKOJOOMCROSS_SERVICES_DESC"
|
|
||||||
showon="mokojoomcross_skip:0">
|
|
||||||
{$options}
|
|
||||||
</field>
|
|
||||||
<field
|
|
||||||
name="mokojoomcross_evergreen"
|
|
||||||
type="radio"
|
|
||||||
label="PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN"
|
|
||||||
description="PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN_DESC"
|
|
||||||
default="0"
|
|
||||||
class="btn-group btn-group-yesno"
|
|
||||||
showon="mokojoomcross_skip:0">
|
|
||||||
<option value="0">JNO</option>
|
|
||||||
<option value="1">JYES</option>
|
|
||||||
</field>
|
|
||||||
<field
|
|
||||||
name="mokojoomcross_evergreen_interval"
|
|
||||||
type="number"
|
|
||||||
label="PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN_INTERVAL"
|
|
||||||
description="PLG_CONTENT_MOKOJOOMCROSS_EVERGREEN_INTERVAL_DESC"
|
|
||||||
default="30"
|
|
||||||
min="1"
|
|
||||||
max="365"
|
|
||||||
showon="mokojoomcross_skip:0[AND]mokojoomcross_evergreen:1"
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
</fields>
|
|
||||||
</form>
|
|
||||||
XML;
|
|
||||||
|
|
||||||
$form->load($xml);
|
|
||||||
|
|
||||||
// Cross-post history panel for existing articles
|
|
||||||
$articleId = Factory::getApplication()->input->getInt('id', 0);
|
|
||||||
|
|
||||||
if ($articleId > 0) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('p.status, p.posted_at, p.error_message, s.title AS service_title, s.service_type')
|
|
||||||
->from($db->quoteName('#__mokojoomcross_posts', 'p'))
|
|
||||||
->join('LEFT', $db->quoteName('#__mokojoomcross_services', 's') . ' ON s.id = p.service_id')
|
|
||||||
->where($db->quoteName('p.article_id') . ' = ' . $articleId)
|
|
||||||
->order('p.created DESC');
|
|
||||||
$db->setQuery($query, 0, 10);
|
|
||||||
$history = $db->loadObjectList();
|
|
||||||
|
|
||||||
if (!empty($history)) {
|
|
||||||
$historyHtml = '<div class="mokojoomcross-history">';
|
|
||||||
|
|
||||||
foreach ($history as $post) {
|
|
||||||
$badgeClass = match ($post->status) {
|
|
||||||
'posted' => 'bg-success',
|
|
||||||
'failed' => 'bg-danger',
|
|
||||||
'queued' => 'bg-warning',
|
|
||||||
default => 'bg-secondary',
|
|
||||||
};
|
|
||||||
$historyHtml .= '<div class="mb-1">'
|
|
||||||
. '<span class="badge ' . $badgeClass . ' me-1">' . ucfirst($post->status) . '</span>'
|
|
||||||
. '<small>' . htmlspecialchars($post->service_title ?? '') . '</small>';
|
|
||||||
|
|
||||||
if ($post->posted_at) {
|
|
||||||
$historyHtml .= ' <small class="text-muted">' . HTMLHelper::_('date', $post->posted_at, 'Y-m-d H:i') . '</small>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($post->status === 'failed' && $post->error_message) {
|
|
||||||
$historyHtml .= '<br><small class="text-danger">' . htmlspecialchars(mb_substr($post->error_message, 0, 60)) . '</small>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$historyHtml .= '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$historyHtml .= '</div>';
|
|
||||||
|
|
||||||
// Add the note field first with an empty description, then set the
|
|
||||||
// description via setFieldAttribute() to avoid double-escaping.
|
|
||||||
// Putting raw HTML into an XML attribute via htmlspecialchars() causes
|
|
||||||
// Joomla's note field renderer to display escaped tags since it outputs
|
|
||||||
// the description as raw HTML.
|
|
||||||
$historyXml = '<?xml version="1.0"?>
|
|
||||||
<form><fields name="attribs"><fieldset name="mokojoomcross">
|
|
||||||
<field name="mokojoomcross_history" type="note"
|
|
||||||
label="PLG_CONTENT_MOKOJOOMCROSS_HISTORY"
|
|
||||||
description="" />
|
|
||||||
</fieldset></fields></form>';
|
|
||||||
$form->load($historyXml);
|
|
||||||
$form->setFieldAttribute('mokojoomcross_history', 'description', $historyHtml, 'attribs');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add cross-post status badges before article content in admin.
|
|
||||||
*
|
*
|
||||||
* Joomla 5/6 compatible — accepts both BeforeDisplayEvent and legacy parameters.
|
* @return string HTML to prepend to the article
|
||||||
*/
|
*/
|
||||||
public function onContentBeforeDisplay($event): string
|
public function onContentBeforeDisplay(string $context, &$article, &$params, int $page = 0): string
|
||||||
{
|
{
|
||||||
// Joomla 5/6 compatibility
|
|
||||||
if ($event instanceof \Joomla\CMS\Event\Content\BeforeDisplayEvent) {
|
|
||||||
$context = $event->getContext();
|
|
||||||
$article = $event->getItem();
|
|
||||||
} elseif (is_string($event)) {
|
|
||||||
$context = $event;
|
|
||||||
$article = func_get_arg(1);
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context !== 'com_content.article') {
|
if ($context !== 'com_content.article') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -262,100 +82,4 @@ XML;
|
|||||||
|
|
||||||
return '<div class="mokojoomcross-status mb-2">' . $badges . '</div>';
|
return '<div class="mokojoomcross-status mb-2">' . $badges . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatch cross-post when an article is saved and published.
|
|
||||||
*
|
|
||||||
* Joomla 5/6 compatible — accepts both AfterSaveEvent and legacy parameters.
|
|
||||||
*/
|
|
||||||
public function onContentAfterSave($event): void
|
|
||||||
{
|
|
||||||
// Joomla 5/6 compatibility
|
|
||||||
if ($event instanceof \Joomla\CMS\Event\Content\AfterSaveEvent) {
|
|
||||||
$context = $event->getContext();
|
|
||||||
$article = $event->getItem();
|
|
||||||
$isNew = $event->getIsNew();
|
|
||||||
} else {
|
|
||||||
$context = $event;
|
|
||||||
$article = func_get_arg(1);
|
|
||||||
$isNew = func_get_arg(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context !== 'com_content.article') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((int) ($article->state ?? 0) !== 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
|
|
||||||
if (!$params->get('auto_post_on_publish', 1)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($params->get('post_on_first_publish_only', 0) && !$isNew) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$url .= '&catid=' . $article->catid;
|
|
||||||
}
|
|
||||||
|
|
||||||
CrossPostDispatcher::dispatch($article, $url, 'com_content.article');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatch cross-post when article state changes to published.
|
|
||||||
*
|
|
||||||
* Joomla 5/6 compatible — accepts both ContentChangeStateEvent and legacy parameters.
|
|
||||||
*/
|
|
||||||
public function onContentChangeState($event): void
|
|
||||||
{
|
|
||||||
if ($event instanceof \Joomla\CMS\Event\Content\ContentChangeStateEvent) {
|
|
||||||
$context = $event->getContext();
|
|
||||||
$pks = $event->getPks();
|
|
||||||
$value = $event->getValue();
|
|
||||||
} else {
|
|
||||||
$context = $event;
|
|
||||||
$pks = func_get_arg(1);
|
|
||||||
$value = func_get_arg(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context !== 'com_content.article' || $value !== 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = ComponentHelper::getParams('com_mokojoomcross');
|
|
||||||
|
|
||||||
if (!$params->get('auto_post_on_publish', 1)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = Factory::getDbo();
|
|
||||||
|
|
||||||
foreach ($pks as $pk) {
|
|
||||||
$query = $db->getQuery(true)
|
|
||||||
->select('*')
|
|
||||||
->from('#__content')
|
|
||||||
->where('id = ' . (int) $pk);
|
|
||||||
$db->setQuery($query);
|
|
||||||
$article = $db->loadObject();
|
|
||||||
|
|
||||||
if (!$article) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
|
||||||
|
|
||||||
if (!empty($article->catid)) {
|
|
||||||
$url .= '&catid=' . $article->catid;
|
|
||||||
}
|
|
||||||
|
|
||||||
CrossPostDispatcher::dispatch($article, $url, 'com_content.article');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<extension type="plugin" group="mokojoomcross" method="upgrade">
|
|
||||||
<name>MokoJoomCross - ActivityPub (Fediverse)</name>
|
|
||||||
<version>01.00.26-dev</version>
|
|
||||||
<creationDate>2026-05-28</creationDate>
|
|
||||||
<author>Moko Consulting</author>
|
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
|
||||||
<authorUrl>https://mokoconsulting.tech</authorUrl>
|
|
||||||
<copyright>Copyright (C) 2026 Moko Consulting. All rights reserved.</copyright>
|
|
||||||
<license>GPL-3.0-or-later</license>
|
|
||||||
<description>PLG_MOKOJOOMCROSS_ACTIVITYPUB_DESCRIPTION</description>
|
|
||||||
|
|
||||||
<namespace path="src">Joomla\Plugin\MokoJoomCross\Activitypub</namespace>
|
|
||||||
|
|
||||||
<files>
|
|
||||||
<filename plugin="activitypub">activitypub.php</filename>
|
|
||||||
<folder>src</folder>
|
|
||||||
<folder>services</folder>
|
|
||||||
<folder>language</folder>
|
|
||||||
</files>
|
|
||||||
|
|
||||||
<languages>
|
|
||||||
<language tag="en-GB">language/en-GB/plg_mokojoomcross_activitypub.ini</language>
|
|
||||||
<language tag="en-GB">language/en-GB/plg_mokojoomcross_activitypub.sys.ini</language>
|
|
||||||
</languages>
|
|
||||||
</extension>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
PLG_MOKOJOOMCROSS_ACTIVITYPUB="MokoJoomCross - ActivityPub (Fediverse)"
|
|
||||||
PLG_MOKOJOOMCROSS_ACTIVITYPUB_DESCRIPTION="Cross-post Joomla articles to ActivityPub (Fediverse)."
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
PLG_MOKOJOOMCROSS_ACTIVITYPUB="MokoJoomCross - ActivityPub (Fediverse)"
|
|
||||||
PLG_MOKOJOOMCROSS_ACTIVITYPUB_DESCRIPTION="Cross-post Joomla articles to ActivityPub (Fediverse)."
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage plg_mokojoomcross_activitypub
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Extension\PluginInterface;
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\DI\Container;
|
|
||||||
use Joomla\DI\ServiceProviderInterface;
|
|
||||||
use Joomla\Event\DispatcherInterface;
|
|
||||||
use Joomla\Plugin\MokoJoomCross\Activitypub\Extension\ActivitypubService;
|
|
||||||
|
|
||||||
return new class () implements ServiceProviderInterface {
|
|
||||||
public function register(Container $container): void
|
|
||||||
{
|
|
||||||
$container->set(
|
|
||||||
PluginInterface::class,
|
|
||||||
function (Container $container) {
|
|
||||||
$plugin = new ActivitypubService(
|
|
||||||
$container->get(DispatcherInterface::class),
|
|
||||||
(array) PluginHelper::getPlugin('mokojoomcross', 'activitypub')
|
|
||||||
);
|
|
||||||
$plugin->setApplication(Factory::getApplication());
|
|
||||||
|
|
||||||
return $plugin;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage plg_mokojoomcross_activitypub
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Plugin\MokoJoomCross\Activitypub\Extension;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Service\MokoJoomCrossServiceInterface;
|
|
||||||
use Joomla\Event\SubscriberInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActivityPub (Fediverse) service plugin for MokoJoomCross.
|
|
||||||
*
|
|
||||||
* Works with Mastodon-compatible APIs (Pleroma, Akkoma, Misskey, Pixelfed).
|
|
||||||
* Uses the /api/v1/statuses endpoint with Bearer token auth.
|
|
||||||
*/
|
|
||||||
class ActivitypubService extends CMSPlugin implements SubscriberInterface, MokoJoomCrossServiceInterface
|
|
||||||
{
|
|
||||||
public static function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return ['onMokoJoomCrossGetServices' => 'onMokoJoomCrossGetServices'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onMokoJoomCrossGetServices(&$services): void
|
|
||||||
{
|
|
||||||
$services[] = $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceType(): string { return 'activitypub'; }
|
|
||||||
public function getServiceName(): string { return 'ActivityPub (Fediverse)'; }
|
|
||||||
public function getMaxLength(): int { return 500; }
|
|
||||||
public function supportsMedia(): bool { return true; }
|
|
||||||
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
|
||||||
{
|
|
||||||
$instanceUrl = rtrim($credentials['instance_url'] ?? '', '/');
|
|
||||||
$token = $credentials['access_token'] ?? '';
|
|
||||||
|
|
||||||
if (empty($instanceUrl) || empty($token)) {
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing instance URL or access token.']];
|
|
||||||
}
|
|
||||||
|
|
||||||
$apiUrl = $instanceUrl . '/api/v1/statuses';
|
|
||||||
$payload = json_encode(['status' => mb_substr($message, 0, 500)]);
|
|
||||||
|
|
||||||
$ch = curl_init($apiUrl);
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => $payload,
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
'Authorization: Bearer ' . $token,
|
|
||||||
'Content-Type: application/json',
|
|
||||||
],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 30,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if ($httpCode >= 200 && $httpCode < 300 && !empty($data['id'])) {
|
|
||||||
return ['success' => true, 'platform_post_id' => (string) $data['id'], 'response' => $data];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
|
||||||
{
|
|
||||||
$instanceUrl = rtrim($credentials['instance_url'] ?? '', '/');
|
|
||||||
$token = $credentials['access_token'] ?? '';
|
|
||||||
|
|
||||||
if (empty($instanceUrl) || empty($token)) {
|
|
||||||
return ['valid' => false, 'message' => 'Instance URL and access token are required.', 'account_name' => ''];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ch = curl_init($instanceUrl . '/api/v1/accounts/verify_credentials');
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 10,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if (!empty($data['username'])) {
|
|
||||||
return ['valid' => true, 'message' => 'Connected', 'account_name' => '@' . $data['username'] . '@' . parse_url($instanceUrl, PHP_URL_HOST)];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['valid' => false, 'message' => $data['error'] ?? 'Failed to verify credentials.', 'account_name' => ''];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSupportedMediaTypes(): array
|
|
||||||
{
|
|
||||||
return ['image', 'video'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<extension type="plugin" group="mokojoomcross" method="upgrade">
|
|
||||||
<name>MokoJoomCross - Google Blogger</name>
|
|
||||||
<version>01.00.26-dev</version>
|
|
||||||
<creationDate>2026-05-28</creationDate>
|
|
||||||
<author>Moko Consulting</author>
|
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
|
||||||
<authorUrl>https://mokoconsulting.tech</authorUrl>
|
|
||||||
<copyright>Copyright (C) 2026 Moko Consulting. All rights reserved.</copyright>
|
|
||||||
<license>GPL-3.0-or-later</license>
|
|
||||||
<description>PLG_MOKOJOOMCROSS_BLOGGER_DESCRIPTION</description>
|
|
||||||
|
|
||||||
<namespace path="src">Joomla\Plugin\MokoJoomCross\Blogger</namespace>
|
|
||||||
|
|
||||||
<files>
|
|
||||||
<filename plugin="blogger">blogger.php</filename>
|
|
||||||
<folder>src</folder>
|
|
||||||
<folder>services</folder>
|
|
||||||
<folder>language</folder>
|
|
||||||
</files>
|
|
||||||
|
|
||||||
<languages>
|
|
||||||
<language tag="en-GB">language/en-GB/plg_mokojoomcross_blogger.ini</language>
|
|
||||||
<language tag="en-GB">language/en-GB/plg_mokojoomcross_blogger.sys.ini</language>
|
|
||||||
</languages>
|
|
||||||
</extension>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
PLG_MOKOJOOMCROSS_BLOGGER="MokoJoomCross - Google Blogger"
|
|
||||||
PLG_MOKOJOOMCROSS_BLOGGER_DESCRIPTION="Cross-post Joomla articles to Google Blogger."
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
PLG_MOKOJOOMCROSS_BLOGGER="MokoJoomCross - Google Blogger"
|
|
||||||
PLG_MOKOJOOMCROSS_BLOGGER_DESCRIPTION="Cross-post Joomla articles to Google Blogger."
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage plg_mokojoomcross_blogger
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Extension\PluginInterface;
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Plugin\PluginHelper;
|
|
||||||
use Joomla\DI\Container;
|
|
||||||
use Joomla\DI\ServiceProviderInterface;
|
|
||||||
use Joomla\Event\DispatcherInterface;
|
|
||||||
use Joomla\Plugin\MokoJoomCross\Blogger\Extension\BloggerService;
|
|
||||||
|
|
||||||
return new class () implements ServiceProviderInterface {
|
|
||||||
public function register(Container $container): void
|
|
||||||
{
|
|
||||||
$container->set(
|
|
||||||
PluginInterface::class,
|
|
||||||
function (Container $container) {
|
|
||||||
$plugin = new BloggerService(
|
|
||||||
$container->get(DispatcherInterface::class),
|
|
||||||
(array) PluginHelper::getPlugin('mokojoomcross', 'blogger')
|
|
||||||
);
|
|
||||||
$plugin->setApplication(Factory::getApplication());
|
|
||||||
|
|
||||||
return $plugin;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package MokoJoomCross
|
|
||||||
* @subpackage plg_mokojoomcross_blogger
|
|
||||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
||||||
* @license GNU General Public License version 3 or later; see LICENSE
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Joomla\Plugin\MokoJoomCross\Blogger\Extension;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
|
||||||
use Joomla\Component\MokoJoomCross\Administrator\Service\MokoJoomCrossServiceInterface;
|
|
||||||
use Joomla\Event\SubscriberInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Google Blogger service plugin for MokoJoomCross.
|
|
||||||
*
|
|
||||||
* Uses the Blogger API v3 with OAuth Bearer token.
|
|
||||||
*/
|
|
||||||
class BloggerService extends CMSPlugin implements SubscriberInterface, MokoJoomCrossServiceInterface
|
|
||||||
{
|
|
||||||
public static function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return ['onMokoJoomCrossGetServices' => 'onMokoJoomCrossGetServices'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onMokoJoomCrossGetServices(&$services): void
|
|
||||||
{
|
|
||||||
$services[] = $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceType(): string { return 'blogger'; }
|
|
||||||
public function getServiceName(): string { return 'Google Blogger'; }
|
|
||||||
public function getMaxLength(): int { return 0; }
|
|
||||||
public function supportsMedia(): bool { return true; }
|
|
||||||
|
|
||||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
|
||||||
{
|
|
||||||
$token = $credentials['access_token'] ?? '';
|
|
||||||
$blogId = $credentials['blog_id'] ?? '';
|
|
||||||
|
|
||||||
if (empty($token) || empty($blogId)) {
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing access token or blog ID.']];
|
|
||||||
}
|
|
||||||
|
|
||||||
$apiUrl = 'https://www.googleapis.com/blogger/v3/blogs/' . urlencode($blogId) . '/posts';
|
|
||||||
$payload = json_encode([
|
|
||||||
'kind' => 'blogger#post',
|
|
||||||
'title' => mb_substr(strip_tags($message), 0, 150),
|
|
||||||
'content' => $message,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$ch = curl_init($apiUrl);
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => $payload,
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
'Authorization: Bearer ' . $token,
|
|
||||||
'Content-Type: application/json',
|
|
||||||
],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 30,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if ($httpCode >= 200 && $httpCode < 300 && !empty($data['id'])) {
|
|
||||||
return ['success' => true, 'platform_post_id' => (string) $data['id'], 'response' => $data];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateCredentials(array $credentials): array
|
|
||||||
{
|
|
||||||
$token = $credentials['access_token'] ?? '';
|
|
||||||
$blogId = $credentials['blog_id'] ?? '';
|
|
||||||
|
|
||||||
if (empty($token) || empty($blogId)) {
|
|
||||||
return ['valid' => false, 'message' => 'Access token and blog ID are required.', 'account_name' => ''];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ch = curl_init('https://www.googleapis.com/blogger/v3/blogs/' . urlencode($blogId));
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token],
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TIMEOUT => 10,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
$data = json_decode($response, true) ?: [];
|
|
||||||
|
|
||||||
if (!empty($data['name'])) {
|
|
||||||
return ['valid' => true, 'message' => 'Connected', 'account_name' => $data['name']];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['valid' => false, 'message' => $data['error']['message'] ?? 'Failed to verify credentials.', 'account_name' => ''];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSupportedMediaTypes(): array
|
|
||||||
{
|
|
||||||
return ['image'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<!DOCTYPE html><title></title>
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="plugin" group="mokojoomcross" method="upgrade">
|
<extension type="plugin" group="mokojoomcross" method="upgrade">
|
||||||
<name>MokoJoomCross - Bluesky</name>
|
<name>MokoJoomCross - Bluesky</name>
|
||||||
<version>01.00.26-dev</version>
|
<version>01.00.00-dev</version>
|
||||||
<creationDate>2026-05-28</creationDate>
|
<creationDate>2026-05-28</creationDate>
|
||||||
<author>Moko Consulting</author>
|
<author>Moko Consulting</author>
|
||||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||||
@@ -23,29 +23,4 @@
|
|||||||
<language tag="en-GB">language/en-GB/plg_mokojoomcross_bluesky.ini</language>
|
<language tag="en-GB">language/en-GB/plg_mokojoomcross_bluesky.ini</language>
|
||||||
<language tag="en-GB">language/en-GB/plg_mokojoomcross_bluesky.sys.ini</language>
|
<language tag="en-GB">language/en-GB/plg_mokojoomcross_bluesky.sys.ini</language>
|
||||||
</languages>
|
</languages>
|
||||||
|
|
||||||
<config>
|
|
||||||
<fields name="params">
|
|
||||||
<fieldset name="basic" label="PLG_MOKOJOOMCROSS_BLUESKY_FIELDSET_DEFAULTS">
|
|
||||||
<field
|
|
||||||
name="default_pds_url"
|
|
||||||
type="url"
|
|
||||||
label="PLG_MOKOJOOMCROSS_BLUESKY_DEFAULT_PDS_URL"
|
|
||||||
description="PLG_MOKOJOOMCROSS_BLUESKY_DEFAULT_PDS_URL_DESC"
|
|
||||||
default="https://bsky.social"
|
|
||||||
/>
|
|
||||||
<field
|
|
||||||
name="auto_link_card"
|
|
||||||
type="radio"
|
|
||||||
label="PLG_MOKOJOOMCROSS_BLUESKY_AUTO_LINK_CARD"
|
|
||||||
description="PLG_MOKOJOOMCROSS_BLUESKY_AUTO_LINK_CARD_DESC"
|
|
||||||
default="1"
|
|
||||||
class="btn-group btn-group-yesno"
|
|
||||||
>
|
|
||||||
<option value="0">JNO</option>
|
|
||||||
<option value="1">JYES</option>
|
|
||||||
</field>
|
|
||||||
</fieldset>
|
|
||||||
</fields>
|
|
||||||
</config>
|
|
||||||
</extension>
|
</extension>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user