v1.0 assessment: fix all blockers, add MokoSuiteShop, close 18 issues #54

Merged
jmiller merged 156 commits from dev into main 2026-06-21 22:01:41 +00:00
149 changed files with 5843 additions and 2289 deletions
+62
View File
@@ -0,0 +1,62 @@
# Auto detect text files and perform LF normalization
* text=auto
# PHP files
*.php text eol=lf
# XML manifests
*.xml text eol=lf
# Language files
*.ini text eol=lf
# SQL files
*.sql text eol=lf
# Shell scripts
*.sh text eol=lf
# Markdown
*.md text eol=lf
# YAML
*.yml text eol=lf
*.yaml text eol=lf
# CSS/JS
*.css text eol=lf
*.js text eol=lf
# JSON
*.json text eol=lf
# Windows scripts
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Binary files
*.zip binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.webp binary
*.woff binary
*.woff2 binary
*.ttf binary
*.eot binary
# Export ignore (not included in archives)
.mokogitea/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.gitmessage export-ignore
CLAUDE.md export-ignore
CONTRIBUTING.md export-ignore
CODE_OF_CONDUCT.md export-ignore
Makefile export-ignore
composer.json export-ignore
phpstan.neon export-ignore
+204
View File
@@ -0,0 +1,204 @@
# ============================================================
# Local task tracking (not version controlled)
# ============================================================
TODO.md
# ============================================================
# Environment and secrets
# ============================================================
.env
.env.local
.env.*.local
*.local.php
*.secret.php
configuration.php
configuration.*.php
configuration.local.php
conf/conf.php
conf/conf*.php
secrets/
*.secrets.*
# ============================================================
# Logs, dumps and databases
# ============================================================
*.db
*.db-journal
*.dump
*.log
*.pid
*.seed
# ============================================================
# OS / Editor / IDE cruft
# ============================================================
.DS_Store
Thumbs.db
desktop.ini
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
$RECYCLE.BIN/
System Volume Information/
*.lnk
Icon?
.idea/
.settings/
.claude/
.vscode/*
!.vscode/tasks.json
!.vscode/settings.json.example
!.vscode/extensions.json
*.code-workspace
*.sublime*
.project
.buildpath
.classpath
*.bak
*.swp
*.swo
*.tmp
*.old
*.orig
# ============================================================
# Dev scripts and scratch
# ============================================================
TODO.md
todo*
*ffs*
# ============================================================
# SFTP / sync tools
# ============================================================
sftp-config*.json
sftp-config.json.template
sftp-settings.json
# ============================================================
# Sublime SFTP / FTP sync
# ============================================================
*.sublime-project
*.sublime-workspace
*.sublime-settings
.libsass.json
*.ffs*
# ============================================================
# Replit / cloud IDE
# ============================================================
.replit
replit.md
# ============================================================
# Archives / release artifacts
# ============================================================
*.7z
*.rar
*.tar
*.tar.gz
*.tgz
*.zip
artifacts/
release/
releases/
# ============================================================
# Build outputs and site generators
# ============================================================
.mkdocs-build/
.cache/
.parcel-cache/
build/
dist/
out/
/site/
*.map
*.css.map
*.js.map
*.tsbuildinfo
# ============================================================
# CI / test artifacts
# ============================================================
.coverage
.coverage.*
coverage/
coverage.xml
htmlcov/
junit.xml
reports/
test-results/
tests/_output/
.github/local/
.github/workflows/*.log
# ============================================================
# Node / JavaScript
# ============================================================
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
.pnpm-store/
.yarn/
.npmrc
.eslintcache
package-lock.json
# ============================================================
# PHP / Composer tooling
# ============================================================
vendor/
!source/media/vendor/
composer.lock
*.phar
codeception.phar
.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
.phpstan.cache
.phplint-cache
phpmd-cache/
.psalm/
.rector/
# ============================================================
# Python
# ============================================================
__pycache__/
*.py[cod]
*.pyc
*$py.class
*.so
.Python
.eggs/
*.egg
*.egg-info/
.installed.cfg
MANIFEST
develop-eggs/
downloads/
eggs/
parts/
sdist/
var/
wheels/
ENV/
env/
.venv/
venv/
.pytest_cache/
.mypy_cache/
.ruff_cache/
.pyright/
.tox/
.nox/
*.cover
*.coverage
hypothesis/
profile.ps1
.mcp.json
+67
View File
@@ -0,0 +1,67 @@
# MokoJoomOpenGraph
Open Graph, Twitter Card, and social sharing meta tag management for Joomla. Per-article SEO with auto-generation fallback.
## Quick Reference
| Field | Value |
|---|---|
| **Package** | `pkg_mokoog` |
| **Language** | PHP 8.1+ |
| **Branch** | develop on `dev`, merge to `main` (protected) |
| **Wiki** | [MokoJoomOpenGraph Wiki](https://git.mokoconsulting.tech/MokoConsulting/MokoJoomOpenGraph/wiki) |
## Commands
```bash
make build # Build package ZIP
make lint # Run linters
make validate # Validate structure
make release # Full release pipeline
make clean # Clean build artifacts
composer install # Install PHP dependencies
```
## Architecture
Joomla **package** with three sub-extensions:
### com_mokoog (Component)
- Admin backend for viewing/managing all OG tag records
- Joomla 4/5 MVC: `Controller/DisplayController`, `Model/TagsModel`, `View/Tags/HtmlView`, `Table/TagTable`
- Namespace: `Joomla\Component\MokoOG\Administrator`
### plg_system_mokoog (System Plugin)
- Hooks `onBeforeCompileHead` to inject `<meta property="og:*">` and `<meta name="twitter:*">`
- Auto-generates tags from article title, description, images when no custom tags exist
- Supports articles (`com_content`), menu items, extensible content types
### plg_content_mokoog (Content Plugin)
- Hooks `onContentPrepareForm` to add OG fields tab to article/menu editors
- Hooks `onContentAfterSave`/`onContentAfterDelete` to persist/clean OG data
### Database Schema
Single table `#__mokoog_tags`:
- `content_type` + `content_id` = unique key for any content item
- `og_title`, `og_description`, `og_image`, `og_type` = custom OG overrides
- `published` flag for per-item enable/disable
## Rules
- **Never commit** `.claude/`, `.mcp.json`, `TODO.md`, `*.min.css`/`*.min.js`
- **Attribution**: `Authored-by: Moko Consulting`
- **Workflow directory**: `.mokogitea/` (not `.gitea/` or `.github/`)
- **Minification**: handled at build time (CI)
- **Wiki**: documentation lives in the Gitea wiki, not `docs/` files
- **Standards**: [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/moko-platform/wiki/Home)
## Coding Standards
- PHP 8.1+ minimum
- Joomla 4/5 DI container pattern: `services/provider.php` → Extension class
- Legacy stub `.php` file required for plugin loader but empty
- `SubscriberInterface` for event subscription (not `on*` method naming)
- `bind() → check() → store()` for Table operations (not `save()`)
- Language file placement: site (no `folder`) vs admin (`folder="administrator"`)
- SPDX license headers on all PHP files
+66 -66
View File
@@ -1,66 +1,66 @@
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: mokocli.Release
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
# 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 mokocli 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/mokocli/cli" ]; then
echo "MOKO_CLI=/opt/mokocli/cli" >> "$GITHUB_ENV"
else
git clone --depth 1 --branch main --quiet \
"https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/MokoConsulting/mokocli.git" \
/tmp/mokocli
cd /tmp/mokocli && composer install --no-dev --no-interaction --quiet
echo "MOKO_CLI=/tmp/mokocli/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"
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: mokocli.Release
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
# 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 mokocli 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/mokocli/cli" ]; then
echo "MOKO_CLI=/opt/mokocli/cli" >> "$GITHUB_ENV"
else
git clone --depth 1 --branch main --quiet \
"https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/MokoConsulting/mokocli.git" \
/tmp/mokocli
cd /tmp/mokocli && composer install --no-dev --no-interaction --quiet
echo "MOKO_CLI=/tmp/mokocli/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"
+9 -9
View File
@@ -4,8 +4,8 @@
#
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: MokoStandards.Maintenance
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
# INGROUP: moko-platform.Maintenance
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
# PATH: /.gitea/workflows/cleanup.yml
# VERSION: 01.00.00
# BRIEF: Scheduled cleanup — delete merged branches and old workflow runs
@@ -33,17 +33,17 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GA_TOKEN }}
token: ${{ secrets.MOKOGITEA_TOKEN }}
- name: Delete merged branches
env:
GA_TOKEN: ${{ secrets.GA_TOKEN }}
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
run: |
echo "=== Merged Branch Cleanup ==="
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
# List branches via API
BRANCHES=$(curl -sS -H "Authorization: token ${GA_TOKEN}" \
BRANCHES=$(curl -sS -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/branches?limit=50" | jq -r '.[].name')
DELETED=0
@@ -56,7 +56,7 @@ jobs:
# Check if branch is merged into main
if git merge-base --is-ancestor "origin/${BRANCH}" origin/main 2>/dev/null; then
echo " Deleting merged branch: ${BRANCH}"
curl -sS -X DELETE -H "Authorization: token ${GA_TOKEN}" \
curl -sS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/branches/${BRANCH}" 2>/dev/null || true
DELETED=$((DELETED + 1))
fi
@@ -66,20 +66,20 @@ jobs:
- name: Clean old workflow runs
env:
GA_TOKEN: ${{ secrets.GA_TOKEN }}
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
run: |
echo "=== Workflow Run Cleanup ==="
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
CUTOFF=$(date -d "30 days ago" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -v-30d +%Y-%m-%dT%H:%M:%SZ)
# Get old completed runs
RUNS=$(curl -sS -H "Authorization: token ${GA_TOKEN}" \
RUNS=$(curl -sS -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/actions/runs?status=completed&limit=50" | \
jq -r ".workflow_runs[] | select(.created_at < \"${CUTOFF}\") | .id" 2>/dev/null)
DELETED=0
for RUN_ID in $RUNS; do
curl -sS -X DELETE -H "Authorization: token ${GA_TOKEN}" \
curl -sS -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
"${API}/actions/runs/${RUN_ID}" 2>/dev/null || true
DELETED=$((DELETED + 1))
done
+2 -2
View File
@@ -4,8 +4,8 @@
#
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: MokoStandards.Security
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/MokoStandards-API
# INGROUP: moko-platform.Security
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/moko-platform
# PATH: /templates/workflows/gitleaks.yml.template
# VERSION: 01.00.00
# BRIEF: Secret scanning — detect leaked credentials, API keys, and tokens
+1 -1
View File
@@ -5,7 +5,7 @@
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: mokocli.Automation
# VERSION: 01.00.00
# VERSION: 01.01.01
# BRIEF: Auto-create feature branch when an issue is opened
name: "Universal: Issue Branch"
+2 -2
View File
@@ -4,8 +4,8 @@
#
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: MokoStandards.Notifications
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
# INGROUP: moko-platform.Notifications
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
# PATH: /.gitea/workflows/notify.yml
# VERSION: 01.00.00
# BRIEF: Push notifications via ntfy on release success or workflow failure
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+18 -2
View File
@@ -4,8 +4,8 @@
#
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: MokoStandards.Security
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
# INGROUP: moko-platform.Security
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
# PATH: /.gitea/workflows/security-audit.yml
# VERSION: 01.00.00
# BRIEF: Dependency vulnerability scanning for composer and npm packages
@@ -80,3 +80,19 @@ jobs:
-H "Priority: high" \
-d "Security audit found vulnerabilities. Review dependency updates." \
"${NTFY_URL}/${NTFY_TOPIC}" || true
- name: Joomla version audit
if: always()
run: |
if [ -f "monitoring/joomla-version-audit.php" ] && [ -n "$JOOMLA_SITES" ]; then
echo "$JOOMLA_SITES" > /tmp/sites.json
php monitoring/joomla-version-audit.php --sites /tmp/sites.json || true
echo "### Joomla Version Audit" >> $GITHUB_STEP_SUMMARY
rm -f /tmp/sites.json
else
echo "Joomla audit skipped (no script or JOOMLA_SITES_JSON not configured)"
fi
env:
JOOMLA_SITES: ${{ vars.JOOMLA_SITES_JSON }}
+46 -17
View File
@@ -1,27 +1,56 @@
# Changelog
## [Unreleased]
<!-- VERSION: 01.01.01 -->
<!-- VERSION: 01.01.00 -->
All notable changes to MokoOpenGraph will be documented in this file.
All notable changes to MokoSuiteOpenGraph will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [01.01.00] --- 2026-06-19
## [Unreleased]
### Removed
- Removed deploy-manual.yml workflow — switching to Joomla update server method for extension distribution
### Security
- Fix JSON-LD XSS vulnerability via `</script>` injection in content data (#34)
- Add ACL permission checks to Batch and ImportExport controllers (#37)
- Add CSV import file type, MIME type, size, and content_type validation (#35)
- Fix multilingual data corruption in content plugin load/save (#41)
### Added
- Initial package structure with component, system plugin, and content plugin
- Open Graph meta tag injection via system plugin (`onBeforeCompileHead`)
- Twitter/X Card meta tag support (Summary and Summary with Large Image)
- Per-article OG fields in the article editor
- Per-menu-item OG fields in the menu item editor
- Auto-generation of OG tags from article title, description, and images
- Site-wide default OG title and description plugin parameters
- Discord embed color via `theme-color` meta tag (color picker in plugin config)
- LinkedIn article tags: `article:published_time`, `article:modified_time`, `article:author`
- `og:image:width` and `og:image:height` for faster social preview rendering
- `onMokoOGAfterRender` event for third-party plugin extensibility
- Joomla Web Services API for OG tags — full CRUD at `/api/v1/mokoog/tags` (#27)
- Live social preview in article/menu editors (Facebook and Twitter/X card mockups) (#3)
- CSV import/export for bulk OG tag management (#12)
- OG image text overlay generator (#7)
- Multilingual OG tag support with per-language records (#11)
- JSON-LD structured data: Article, Product, WebPage, BreadcrumbList schemas (#6)
- Social platform debugger quick links (Facebook, LinkedIn, Google) (#9)
- MokoSuiteShop product OG tag support with pricing meta and JSON-LD Product schema (#53)
- WhatsApp and Telegram link preview optimization (#10)
- Category-level OG tag support (#4)
- Batch OG tag generation for existing articles (#1)
- Auto-resize OG images to 1200x630px with center crop (#2)
- SEO meta tag management: title, description, robots, canonical URL (#8)
- Per-article and per-menu-item OG fields in the editor
- Auto-generation of OG tags from article content, title, and images
- Default fallback image configuration
- Admin tag manager component for viewing all OG records
- Facebook App ID support
- Database table `#__mokoog_tags` for storing custom OG data
- Admin tag manager component with filtering, search, and pagination
- Facebook App ID and Telegram channel support
- Database table `#__mokoog_tags` with multilingual unique key
### Changed
- Consolidated article DB queries into single cached lookup — 5 queries reduced to 1 (#38)
- Dynamic `og:image:width`/`og:image:height` from actual image dimensions instead of hardcoded (#39)
- Replace GD `@` error suppression with `Log::add()` warnings (#49)
- TagTable::check() validates og_type, field lengths, canonical_url, robots directives (#43)
- CSV import/export now includes language column for multilingual support (#52)
- Batch process limit capped at 200 per request (#42)
- Canonical URL replacement uses public `getHeadData()`/`setHeadData()` API (#39)
- Language-aware queries on `loadOgDataByType()` and `loadOgDataByMenu()` (#47)
### Removed
- Removed dead ContentType adapters (K2, VirtueMart, HikaShop) — not targeting these platforms (#36)
- Removed `<updateservers>` from package manifest — managed externally (#44)
- Removed deploy-manual.yml workflow
-78
View File
@@ -1,78 +0,0 @@
# CLAUDE.md
This file provides guidance to Claude Code when working with this repository.
## Project Overview
**MokoOpenGraph** -- Open Graph, Twitter Card, and social sharing meta tag management for Joomla
| Field | Value |
|---|---|
| **Platform** | joomla |
| **Language** | PHP |
| **Default branch** | main |
| **License** | GPL-3.0-or-later |
| **Wiki** | [MokoOpenGraph Wiki](https://git.mokoconsulting.tech/MokoConsulting/MokoOpenGraph/wiki) |
| **Standards** | [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/moko-platform/wiki/Home) |
## Common Commands
```bash
make build # Build the project
make lint # Run linters
make validate # Validate structure
make release # Full release pipeline
make minify # Minify CSS/JS assets
make clean # Clean build artifacts
```
```bash
composer install # Install PHP dependencies
```
## Architecture
This is a Joomla **package** extension (`pkg_mokoog`) containing three sub-extensions:
### com_mokoog (Component)
- Admin backend for viewing and managing all OG tag records
- Joomla 4/5 MVC: `Controller/DisplayController`, `Model/TagsModel`, `View/Tags/HtmlView`, `Table/TagTable`
- Namespace: `Joomla\Component\MokoOG\Administrator`
- Database table: `#__mokoog_tags` — stores custom OG data per content item
### plg_system_mokoog (System Plugin)
- Hooks `onBeforeCompileHead` to inject `<meta property="og:*">` and `<meta name="twitter:*">` tags
- Auto-generates tags from article title, description, and images when no custom tags exist
- Supports articles (`com_content`), menu items, and extensible content types
- Namespace: `Joomla\Plugin\System\MokoOG`
### plg_content_mokoog (Content Plugin)
- Hooks `onContentPrepareForm` to add OG fields tab to article and menu item editors
- Hooks `onContentAfterSave` / `onContentAfterDelete` to persist/clean OG data
- Namespace: `Joomla\Plugin\Content\MokoOG`
### Database Schema
Single table `#__mokoog_tags`:
- `content_type` + `content_id` = unique key identifying any content item
- `og_title`, `og_description`, `og_image`, `og_type` = custom OG overrides
- `published` flag for enabling/disabling per-item
## Rules
- **Never commit** `.claude/`, `.mcp.json`, `TODO.md`, or `*.min.css`/`*.min.js`
- **Attribution**: use `Authored-by: Moko Consulting` in commits
- **Branch strategy**: develop on `dev`, merge to `main` for release
- **Minification**: handled at build time (CI)
- **Wiki**: documentation lives in the Gitea wiki, not in `docs/` files
- **Standards**: this repo follows [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/moko-platform/wiki/Home)
## Coding Standards
- PHP 8.1+ minimum
- Joomla 4/5 DI container pattern: `services/provider.php` → Extension class
- Legacy stub `.php` file required for plugin loader but empty
- `SubscriberInterface` for event subscription (not `on*` method naming)
- `bind() → check() → store()` for Table operations (not `save()`)
- Language file placement: site (no `folder`) vs admin (`folder="administrator"`)
- SPDX license headers on all PHP files
+28
View File
@@ -0,0 +1,28 @@
# Code of Conduct
## Our Pledge
We pledge to make participation in our project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to a positive environment:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
Examples of unacceptable behavior:
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information without explicit permission
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project team at hello@mokoconsulting.tech. All complaints will be reviewed and investigated.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.
+34 -161
View File
@@ -1,161 +1,34 @@
# Contributing to Moko Consulting Projects
Thank you for your interest in contributing. All Moko Consulting repositories follow this universal workflow and version policy.
## Branching Workflow
```
feature/* ──PR──> dev ──draft PR──> (renamed to rc) ──merge──> main
```
### Step by step
1. **Create a feature branch** from `dev`:
```bash
git checkout dev && git pull
git checkout -b feature/my-change
```
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.
4. **When ready for release**, open a **draft PR**: `dev` → `main`.
- This automatically renames the source branch to `rc` (release candidate)
- An RC pre-release is built and uploaded
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 `alpha` to `beta` for feature-complete testing → beta pre-release is built
- 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`.
7. **Merging to main** triggers the stable release pipeline:
- Minor version bump (e.g., `02.09.xx` → `02.10.00`)
- Stability suffix stripped (clean version)
- Gitea release created with ZIP/tar.gz packages
- `updates.xml` updated (Joomla extensions)
- `dev` branch recreated from `main`
### Branch summary
| Branch | Purpose | Created by |
|--------|---------|-----------|
| `feature/*` | New features and fixes | Developer |
| `dev` | Integration branch | Auto-recreated after release |
| `alpha` | Alpha pre-release testing | Manual rename from `dev` |
| `beta` | Beta pre-release testing | Manual rename from `alpha` |
| `rc` | Release candidate | Auto-renamed on draft PR to main |
| `main` | Stable releases | Protected, merge only |
| `version/XX.YY.ZZ` | Archived release snapshots | Auto-created by CI |
### Protected branches
| Branch | Direct push | Merge via |
|--------|------------|-----------|
| `main` | Blocked (CI bot whitelisted) | PR merge only |
| `dev` | Blocked (CI bot whitelisted) | PR merge from feature/* |
| `rc` | Blocked (CI bot whitelisted) | Auto-created on draft PR |
| `alpha` | Blocked (CI bot whitelisted) | Manual rename |
| `beta` | Blocked (CI bot whitelisted) | Manual rename |
| `feature/*` | Open | N/A (source branch) |
## Version Policy
### Format
All versions use `XX.YY.ZZ` — three two-digit segments, zero-padded:
- **XX** — Major version (breaking changes)
- **YY** — Minor version (new features, bumped on release to main)
- **ZZ** — Patch version (auto-incremented on every push to dev/feature branches)
Rollover: patch `99` → `00` increments minor; minor `99` → `00` increments major.
### Stability suffixes
Each branch appends a suffix to indicate stability:
| Branch | Suffix | Example |
|--------|--------|---------|
| `main` | (none) | `02.09.00` |
| `dev` | `-dev` | `02.09.01-dev` |
| `feature/*` | `-dev` | `02.09.01-dev` |
| `alpha` | `-alpha` | `02.09.01-alpha` |
| `beta` | `-beta` | `02.09.01-beta` |
| `rc` | `-rc` | `02.09.01-rc` |
### Auto version bump
On every push to `dev`, `feature/*`, or `patch/*`:
1. Patch version incremented
2. Stability suffix `-dev` applied
3. All version-bearing files updated (manifests, CHANGELOG, PHP headers, etc.)
4. Commit created with `[skip ci]` to avoid loops
### Release version flow
Version bumps happen at specific release events:
| Event | Bump | Example |
|-------|------|---------|
| 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` |
| 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` |
### Release stream copies
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`
- **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).
### Version files
The version tools update all files containing version stamps:
- `.mokogitea/manifest.xml` (canonical source)
- Joomla XML manifests (`<version>` tag)
- `README.md`, `CHANGELOG.md` (`VERSION:` pattern)
- `package.json`, `pyproject.toml`
- Any text file with a `VERSION: XX.YY.ZZ` label
Files synced from other repos (with a `# REPO:` header) are not touched.
## Code Standards
- **PHP**: PSR-12, tabs for indentation
- **Copyright**: all files must include the Moko Consulting copyright header
- **License**: SPDX identifier `GPL-3.0-or-later` (or as specified per repo)
- **Attribution**: use `Authored-by: Moko Consulting` in commits, not individual names
## Commit Messages
Use conventional commit format:
```
type(scope): short description
Optional body with context.
Authored-by: Moko Consulting
```
Types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `test`, `ci`
Special flags in commit messages:
- `[skip ci]` — skip all CI workflows
- `[skip bump]` — skip auto version bump only
## Reporting Issues
Use the repository's issue tracker with the appropriate template.
---
*Moko Consulting <hello@mokoconsulting.tech>*
# Contributing to MokoJoomOpenGraph
Thank you for your interest in contributing to MokoJoomOpenGraph.
## Getting Started
1. Fork the repository on Gitea
2. Create a feature branch from `dev` (`feature/your-feature`)
3. Make your changes following the coding standards below
4. Submit a pull request targeting `dev`
## Branch Strategy
- `main` — stable releases only
- `dev` — active development
- `feature/*` — new features (target `dev`)
- `fix/*` — bug fixes (target `dev`)
- `hotfix/*` — urgent fixes (target `dev` or `main`)
## Coding Standards
- PHP 8.1+ required
- Follow Joomla coding standards
- SPDX license headers on all PHP files
- Use `SubscriberInterface` for event subscription
- Use `bind() -> check() -> store()` for Table operations
## Reporting Issues
Report bugs and feature requests via [Issues](https://git.mokoconsulting.tech/MokoConsulting/MokoJoomOpenGraph/issues).
## License
By contributing, you agree that your contributions will be licensed under GPL-3.0-or-later.
+318
View File
@@ -0,0 +1,318 @@
# MokoSuiteOpenGraph — Code Assessment Issues
Generated: 2026-06-06
Updated: 2026-06-21
Reviewed: Full codebase (all PHP, SQL, XML, JS, CSS, templates)
---
## Status Legend
- FIXED — Verified resolved in codebase
- OPEN — Still present, needs work
- WONTFIX — Intentional or acceptable as-is
---
## Bugs
### BUG-01: Batch generation offset pagination skips articles — FIXED
**Severity:** High
**File:** `source/packages/com_mokoog/src/Controller/BatchController.php:89`
The `process()` method now correctly uses `$db->setQuery($query, 0, $limit)` with a comment explaining that processed articles are automatically excluded by the LEFT JOIN filter.
---
### BUG-02: License key session flag set before check completes — FIXED
**Severity:** Medium
**File:** `source/packages/plg_system_mokoog/src/Extension/MokoOG.php:543`
Session flag is now set after the DB query succeeds, inside the try block but after query setup. If the query throws, the catch block runs without the flag being set.
---
### BUG-03: Hardcoded og:image dimensions are often wrong — FIXED
**Severity:** Medium
**File:** `source/packages/plg_system_mokoog/src/Extension/MokoOG.php:129-134`
Now uses `$this->getImageDimensions($image)` which calls `getimagesize()` to detect actual dimensions. Dimension meta tags only emitted when dimensions are successfully detected.
---
### BUG-04: `strlen()` vs `mb_strlen()` inconsistency in truncation — FIXED
**Severity:** Low
**Files:** MokoOG.php, BatchController.php, HikaShopAdapter.php, K2Adapter.php
All instances now consistently use `mb_strlen()` for length checks with `mb_substr()` for truncation.
---
### BUG-05: `ImageGenerator::wrapText()` can produce broken output — FIXED
**Severity:** Low
**File:** `source/packages/plg_system_mokoog/src/Helper/ImageGenerator.php:156`
Now checks `mb_strlen($lines[2]) > 3` before truncating. Short lines get `'...'` appended instead.
---
## Potential Issues
### ISSUE-01: ContentType adapters exist but are never wired up — OPEN
**Severity:** High (wasted code)
**Files:**
- `source/packages/com_mokoog/src/ContentType/ContentTypeInterface.php`
- `source/packages/com_mokoog/src/ContentType/HikaShopAdapter.php`
- `source/packages/com_mokoog/src/ContentType/K2Adapter.php`
- `source/packages/com_mokoog/src/ContentType/VirtueMartAdapter.php`
The system plugin (`MokoOG.php`) still never references or loads these adapters. The `findImage()` and `loadOgData()` methods only handle `com_content`. Third-party content types get no auto-generated OG tags.
**Action:** Wire adapters into the system plugin's `onBeforeCompileHead` flow, or remove them if not planned for v1.
---
### ISSUE-02: `applySeoTags()` accesses internal `$doc->_links` property — OPEN
**Severity:** Medium
**File:** `source/packages/plg_system_mokoog/src/Extension/MokoOG.php:257-259`
Still directly accessing `$doc->_links` (protected/internal property). Fragile across Joomla versions.
**Fix:** Use `$doc->getHeadData()` to read links and `$doc->addHeadLink()` with proper clearing logic.
---
### ISSUE-03: No input sanitization on OG values before output — OPEN
**Severity:** Medium
**File:** `source/packages/plg_content_mokoog/src/Extension/MokoOGContent.php`
No `htmlspecialchars()` or `InputFilter` found in the content plugin's save path. While Joomla's `setMetaData()` escapes on output, defense-in-depth recommends sanitizing on input.
**Fix:** Apply `htmlspecialchars()` or Joomla's `InputFilter` when saving OG data.
---
### ISSUE-04: `loadOgDataByType()` and `loadOgDataByMenu()` ignore language — OPEN
**Severity:** Medium
**Files:**
- `source/packages/plg_system_mokoog/src/Extension/MokoOG.php:324-337` (`loadOgDataByType`)
- `source/packages/plg_system_mokoog/src/Extension/MokoOG.php:346-359` (`loadOgDataByMenu`)
These methods still have no language filter. On multilingual sites, category fallback or menu OG data could come from any language. The unique key is now `(content_type, content_id, language)` but these queries don't filter by language, so `loadObject()` returns an arbitrary match.
**Fix:** Add the same language filter pattern used in `loadOgData()`.
---
### ISSUE-05: VirtueMart adapter interpolates language into table name — OPEN (low risk)
**Severity:** Low (defense-in-depth)
**File:** `source/packages/com_mokoog/src/ContentType/VirtueMartAdapter.php:34,47`
Language tag is interpolated into the table name. While `quoteName()` wraps the result, the language tag itself is not validated against an allowlist.
**Fix:** Validate tag format with a regex before interpolation.
---
### ISSUE-06: No admin list controller for publish/delete operations — OPEN
**Severity:** Medium
**File:** `source/packages/com_mokoog/src/Controller/`
No `TagsController extends AdminController` exists. The admin list view toolbar buttons for delete/publish/unpublish will produce task routing errors.
**Fix:** Add a `TagsController extends AdminController` with proper CSRF and ACL checks.
---
### ISSUE-07: CSV import/export does not handle `language` column — OPEN
**Severity:** Low
**File:** `source/packages/com_mokoog/src/Controller/ImportExportController.php`
No reference to `language` found in the controller. Export omits the column, import creates records with default `*` language. Multilingual sites cannot bulk import/export language-specific OG data.
**Fix:** Add `language` as a column in export, and parse it on import with a fallback to `*`.
---
### ISSUE-08: No ACL check in content plugin form injection — WONTFIX
**Severity:** Low
**File:** `source/packages/plg_content_mokoog/src/Extension/MokoOGContent.php:49`
Any user who can edit an article can modify OG tags. This is acceptable behavior for most sites — if you can edit the article, you should be able to control its social sharing appearance.
---
## New Issues (Found 2026-06-21)
### ISSUE-09: ImageGenerator uses @ error suppression on GD functions
**Severity:** Medium
**File:** `source/packages/plg_system_mokoog/src/Helper/ImageGenerator.php`
All GD library calls use the `@` suppression operator, making debugging difficult. If the GD extension is missing or a font file is not found, failures are completely silent.
**Fix:** Replace `@` suppression with proper error checking and logging via `Log::add()`.
---
### ISSUE-10: No TTF font file bundled or documented
**Severity:** Medium
**File:** `source/packages/plg_system_mokoog/src/Helper/ImageGenerator.php`
The image generator requires a TTF font file for text overlay, but no font is included in the package and no fallback or documentation exists for configuring the font path.
**Fix:** Bundle a permissively-licensed font (e.g., Open Sans, Noto Sans) or document the required configuration.
---
### ISSUE-11: ImageGenerator cache grows unbounded
**Severity:** Low
**File:** `source/packages/plg_system_mokoog/src/Helper/ImageGenerator.php`
Generated images in `images/mokoog/generated/` are never cleaned up. On sites with many articles, this directory grows indefinitely.
**Fix:** Add a cleanup CLI command or admin button (see FEAT-07), or implement LRU/TTL-based cache eviction.
---
### ISSUE-12: JSON-LD missing common schema types
**Severity:** Low
**File:** `source/packages/plg_system_mokoog/src/Helper/JsonLdBuilder.php`
Only 4 schema types are implemented (Article, WebPage, BreadcrumbList, Organization). Missing: NewsArticle, BlogPosting, Product, VideoObject, Event — some of which correspond to existing `og_type` dropdown values.
**Fix:** Add at least NewsArticle and BlogPosting as Article subtypes.
---
### ISSUE-13: No API input validation beyond field whitelisting
**Severity:** Low
**Files:**
- `source/packages/com_mokoog/api/src/Controller/TagsController.php`
- `source/packages/com_mokoog/api/src/View/Tags/JsonapiView.php`
The REST API exposes full CRUD but has no validation for field content (e.g., max lengths, valid URLs for og_image/canonical_url, valid og_type values).
**Fix:** Add validation rules matching the form XML constraints.
---
## Feature Expansion Opportunities
### FEAT-01: Wire up ContentType adapter system — NOT IMPLEMENTED
Connect the existing `ContentTypeInterface` adapters to the system plugin so HikaShop products, K2 items, and VirtueMart products automatically get OG tags. Blocked by ISSUE-01.
---
### FEAT-02: Admin edit view for individual OG tag records — NOT IMPLEMENTED
A `TagModel` and `tag.xml` form exist but there's no edit template (`tmpl/tag/`) or `TagController`. Users can only manage OG tags through article/menu editors.
---
### FEAT-03: Publish/unpublish toggle in admin list — NOT IMPLEMENTED
Blocked by ISSUE-06 (no TagsController). The list view shows published status as text but has no clickable toggle.
---
### FEAT-04: Actual image dimension detection for og:image meta — FIXED
Implemented via `getImageDimensions()` method using `getimagesize()`. See BUG-03.
---
### FEAT-05: Duplicate OG tag detection — NOT IMPLEMENTED
No detection for conflicting OG meta tags from other extensions.
---
### FEAT-06: Support og:video and og:audio URLs — NOT IMPLEMENTED
No `og_video` or `og_audio` columns, form fields, or rendering logic found anywhere in the codebase.
---
### FEAT-07: Generated image cache cleanup — NOT IMPLEMENTED
No CLI command or admin purge button. See ISSUE-11.
---
### FEAT-08: Sitemap integration — NOT IMPLEMENTED
No sitemap generation or integration exists.
---
### FEAT-09: Social share preview in admin list — NOT IMPLEMENTED
No thumbnails or inline validation in the admin list view. Live preview only exists in the article/menu editor (via plg_content_mokoog).
---
### FEAT-10: Bulk OG tag editing — NOT IMPLEMENTED
No batch edit modal for selecting multiple items and changing common fields.
---
## Security Fixes (from CHANGELOG [Unreleased])
All 4 claimed security fixes have been **verified as implemented**:
| Fix | Status | Evidence |
|-----|--------|----------|
| JSON-LD XSS (#34) | IMPLEMENTED | `</` escaping in `JsonLdBuilder::toScriptTag()` |
| ACL on Batch/ImportExport (#37) | IMPLEMENTED | `authorise()` checks on all controller methods |
| CSV import validation (#35) | IMPLEMENTED | File type, MIME, size (2MB), content_type regex |
| Multilingual data corruption (#41) | IMPLEMENTED | Language-aware load/save in content plugin |
Additional security review found **no vulnerabilities** for: SQL injection, CSRF, file upload, path traversal, code injection, or XSS in output.
---
## Summary
| Category | Total | Fixed | Open | Won't Fix |
|----------|-------|-------|------|-----------|
| Bugs | 5 | 5 | 0 | 0 |
| Issues | 13 | 0 | 12 | 1 |
| Features | 10 | 1 | 9 | 0 |
| Security | 4 | 4 | 0 | 0 |
### Priority for v1.0.0 Release
**Must fix:**
- ISSUE-06: TagsController for admin list operations (publish/delete broken)
- ISSUE-04: Language filter on loadOgDataByType/loadOgDataByMenu (data integrity on multilingual sites)
**Should fix:**
- ISSUE-02: Replace `$doc->_links` access (Joomla version fragility)
- ISSUE-03: Input sanitization on save (defense-in-depth)
- ISSUE-09: GD error suppression (debuggability)
- ISSUE-10: Bundle or document TTF font requirement
**Nice to have for v1.0.0:**
- FEAT-02: Admin edit view
- FEAT-03: Publish/unpublish toggle
- ISSUE-07: Language column in CSV import/export
+1 -1
View File
@@ -2,7 +2,7 @@
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# MokoOpenGraph — Open Graph & social sharing meta tag management
# MokoJoomOpenGraph — Open Graph & social sharing meta tag management
# ==============================================================================
# CONFIGURATION - Customize these for your extension
+44 -15
View File
@@ -1,40 +1,69 @@
# MokoOpenGraph
# MokoSuiteOpenGraph
<!-- VERSION: 01.01.00 -->
<!-- VERSION: 01.01.01 -->
Open Graph, Twitter Card, and social sharing meta tag management for Joomla 4/5/6.
## Overview
MokoOpenGraph gives you full control over how your Joomla content appears when shared on Facebook, Twitter/X, LinkedIn, WhatsApp, and other social platforms. Set custom titles, descriptions, and images per article and menu item — or let the extension auto-generate them from your existing content.
MokoSuiteOpenGraph gives you full control over how your Joomla content appears when shared on Facebook, Twitter/X, LinkedIn, Discord, WhatsApp, Telegram, and other social platforms. Set custom titles, descriptions, and images per article, menu item, and category — or let the extension auto-generate them from your existing content.
## Features
- **Open Graph tags** — `og:title`, `og:description`, `og:image`, `og:url`, `og:type`, `og:site_name`
### Social Meta Tags
- **Open Graph tags** — `og:title`, `og:description`, `og:image`, `og:url`, `og:type`, `og:site_name`, `og:locale`
- **Twitter/X Cards** — Summary and Summary with Large Image card types
- **Per-article control** — Custom OG fields in the article editor
- **LinkedIn** — `article:published_time`, `article:modified_time`, `article:author`
- **Discord** — Custom embed color via `theme-color` meta tag
- **Telegram** — `telegram:channel` for link previews
- **Facebook** — `fb:app_id` support, `og:image:width`/`og:image:height` for instant previews
### Content Management
- **Per-article control** — Custom OG fields tab in the article editor
- **Per-menu-item control** — Custom OG fields in the menu item editor
- **Auto-generation** — Automatically builds tags from article content, title, and images
- **Default fallback image** — Site-wide default when no article image exists
- **Admin tag manager** — View and manage all OG records from a central dashboard
- **Facebook App ID** — Optional `fb:app_id` meta tag support
- **Joomla 4/5/6** — Modern DI container architecture, Joomla coding standards
- **Per-category control** — Category-level OG tag overrides
- **Multilingual support** — Per-language OG data with language-aware fallback
- **Auto-generation** — Builds tags from article content, title, and images automatically
- **Site-wide defaults** — Default OG title, description, and image for all pages
### SEO
- **SEO title override** — Custom `<title>` tag per page
- **Meta description** — Per-page meta description control
- **Robots directive** — Per-page noindex/nofollow settings
- **Canonical URL** — Custom canonical URL overrides
- **JSON-LD structured data** — Article, Product, WebPage, BreadcrumbList, Organization schemas
### Admin Tools
- **Tag manager dashboard** — View and manage all OG records centrally
- **Batch generation** — Auto-generate OG tags for all existing articles
- **CSV import/export** — Bulk manage OG data via CSV files
- **SEO health badges** — Visual indicators for missing descriptions, long titles, noindex
- **Debug links** — Quick links to Facebook Debugger, LinkedIn Inspector, Google Rich Results
- **Live preview** — Real-time Facebook and Twitter/X card preview in the editor
### Developer Features
- **REST API** — Full CRUD via Joomla Web Services (`/api/v1/mokoog/tags`)
- **MokoSuiteShop integration** — Auto-generated OG/JSON-LD for product pages with pricing meta
- **Plugin event** — `onMokoOGAfterRender` for third-party plugins to add custom social tags
- **OG image generator** — Text overlay on template backgrounds with auto-resize to 1200x630
## Installation
1. Download the latest `pkg_mokoog-*.zip` from [Releases](https://git.mokoconsulting.tech/MokoConsulting/MokoOpenGraph/releases)
1. Download the latest `pkg_mokoog-*.zip` from [Releases](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteOpenGraph/releases)
2. In Joomla Administrator → Extensions → Install → Upload Package File
3. The system plugin is enabled automatically on install
3. All plugins are enabled automatically on install
## Configuration
Navigate to **Extensions → Plugins → System - MokoOpenGraph** to configure:
Navigate to **Extensions → Plugins → System - MokoSuiteOpenGraph** to configure:
- Site name override
- Default OG title and description (site-wide fallback)
- Default fallback image
- Twitter Card type and @username
- Facebook App ID
- Auto-generation behavior
- Description length limit
- Discord embed color
- Telegram channel
- Auto-generation, image resize, JSON-LD, and description length settings
## License
+3 -1
View File
@@ -17,8 +17,10 @@
"require-dev": {
"squizlabs/php_codesniffer": "^3.7",
"phpstan/phpstan": "^1.10",
"joomla/coding-standards": "^4.0"
"joomla/coding-standards": "^3.0"
},
"minimum-stability": "alpha",
"prefer-stable": true,
"config": {
"sort-packages": true
}
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,7 +1,7 @@
; MokoOpenGraph - Package System Language File
; MokoJoomOpenGraph - Package System Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PKG_MOKOOG="MokoOpenGraph"
PKG_MOKOOG="MokoJoomOpenGraph"
PKG_MOKOOG_DESCRIPTION="Complete Open Graph, Twitter Card, and social sharing meta tag management for Joomla. Control how every page appears when shared on Facebook, Twitter/X, LinkedIn, WhatsApp, and more."
PKG_MOKOOG_PHP_VERSION_ERROR="MokoOpenGraph requires PHP %s or later."
PKG_MOKOOG_PHP_VERSION_ERROR="MokoJoomOpenGraph requires PHP %s or later."
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,7 +1,7 @@
; MokoOpenGraph - Package System Language File
; MokoJoomOpenGraph - Package System Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PKG_MOKOOG="MokoOpenGraph"
PKG_MOKOOG="MokoJoomOpenGraph"
PKG_MOKOOG_DESCRIPTION="Complete Open Graph, Twitter Card, and social sharing meta tag management for Joomla. Control how every page appears when shared on Facebook, Twitter/X, LinkedIn, WhatsApp, and more."
PKG_MOKOOG_PHP_VERSION_ERROR="MokoOpenGraph requires PHP %s or later."
PKG_MOKOOG_PHP_VERSION_ERROR="MokoJoomOpenGraph requires PHP %s or later."
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,68 @@
<?php
/**
* @package MokoJoomOpenGraph
* @subpackage com_mokoog.api
* @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
*/
namespace Joomla\Component\MokoOG\Api\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\ApiController;
class TagsController extends ApiController
{
/**
* The content type for JSON:API output.
*
* @var string
*/
protected $contentType = 'tags';
/**
* The default view for the API.
*
* @var string
*/
protected $default_view = 'tags';
/**
* Lookup an OG tag by content_type and content_id.
*
* GET /api/index.php/v1/mokoog/lookup/:content_type/:content_id
*
* @return static
*/
public function lookup(): static
{
$contentType = $this->input->getString('content_type', '');
$contentId = $this->input->getInt('content_id', 0);
if (empty($contentType) || $contentId <= 0) {
throw new \RuntimeException('content_type and content_id are required', 400);
}
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__mokoog_tags'))
->where($db->quoteName('content_type') . ' = ' . $db->quote($contentType))
->where($db->quoteName('content_id') . ' = ' . $contentId);
$db->setQuery($query);
$id = $db->loadResult();
if (!$id) {
throw new \RuntimeException('OG tag not found for ' . $contentType . ':' . $contentId, 404);
}
$this->input->set('id', $id);
return $this->displayItem();
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,66 @@
<?php
/**
* @package MokoJoomOpenGraph
* @subpackage com_mokoog.api
* @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
*/
namespace Joomla\Component\MokoOG\Api\View\Tags;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
class JsonapiView extends BaseApiView
{
/**
* The fields to render in the API response.
*
* Whitelist of fields from #__mokoog_tags that are safe to expose.
*
* @var array
*/
protected $fieldsToRenderItem = [
'id',
'content_type',
'content_id',
'og_title',
'og_description',
'og_image',
'og_type',
'seo_title',
'meta_description',
'robots',
'canonical_url',
'language',
'published',
'created',
'modified',
];
/**
* The fields to render in list responses.
*
* @var array
*/
protected $fieldsToRenderList = [
'id',
'content_type',
'content_id',
'og_title',
'og_description',
'og_image',
'og_type',
'seo_title',
'meta_description',
'robots',
'canonical_url',
'language',
'published',
'created',
'modified',
];
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -70,4 +70,37 @@
<option value="0">JUNPUBLISHED</option>
</field>
</fieldset>
<fieldset name="seo" label="SEO Meta Tags">
<field
name="seo_title"
type="text"
label="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE"
description="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE_DESC"
filter="string"
maxlength="70"
/>
<field
name="meta_description"
type="textarea"
label="PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION"
description="PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION_DESC"
filter="string"
rows="3"
maxlength="200"
/>
<field
name="robots"
type="text"
label="PLG_CONTENT_MOKOOG_FIELD_ROBOTS"
description="PLG_CONTENT_MOKOOG_FIELD_ROBOTS_DESC"
filter="string"
/>
<field
name="canonical_url"
type="url"
label="PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL"
description="PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL_DESC"
filter="url"
/>
</fieldset>
</form>
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,59 @@
; MokoJoomOpenGraph - Component Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
COM_MOKOOG="MokoJoomOpenGraph"
COM_MOKOOG_TAGS_TITLE="MokoJoomOpenGraph - Tag Manager"
COM_MOKOOG_SUBMENU_TAGS="Tags"
COM_MOKOOG_NO_TAGS="No Open Graph tags have been created yet. Tags are created automatically when you edit articles or menu items."
COM_MOKOOG_TABLE_CAPTION="Table of Open Graph tags"
COM_MOKOOG_AUTO_GENERATED="auto-generated"
COM_MOKOOG_HEADING_CONTENT_TYPE="Content Type"
COM_MOKOOG_HEADING_CONTENT_ID="Content ID"
COM_MOKOOG_HEADING_OG_TITLE="OG Title"
COM_MOKOOG_HEADING_IMAGE="Image"
COM_MOKOOG_HEADING_SEO="SEO"
COM_MOKOOG_HEADING_DEBUG="Debug"
COM_MOKOOG_HEADING_MODIFIED="Modified"
COM_MOKOOG_SEO_OK="OK"
COM_MOKOOG_SEO_MISSING_DESC="No meta description"
COM_MOKOOG_SEO_TITLE_LONG="SEO title too long"
COM_MOKOOG_SEO_NOINDEX="noindex"
COM_MOKOOG_FIELD_CONTENT_TYPE="Content Type"
COM_MOKOOG_FIELD_CONTENT_ID="Content ID"
COM_MOKOOG_FIELD_OG_TITLE="OG Title"
COM_MOKOOG_FIELD_OG_TITLE_DESC="Custom title for social sharing."
COM_MOKOOG_FIELD_OG_DESCRIPTION="OG Description"
COM_MOKOOG_FIELD_OG_DESCRIPTION_DESC="Custom description for social sharing."
COM_MOKOOG_FIELD_OG_IMAGE="OG Image"
COM_MOKOOG_FIELD_OG_IMAGE_DESC="Custom image for social sharing."
COM_MOKOOG_FIELD_OG_TYPE="OG Type"
COM_MOKOOG_FIELD_OG_TYPE_DESC="The Open Graph content type."
COM_MOKOOG_FILTER_SEARCH="Search OG titles"
COM_MOKOOG_FILTER_CONTENT_TYPE="Content Type"
COM_MOKOOG_FILTER_SELECT_TYPE="- Select Type -"
COM_MOKOOG_HEADING_OG_TITLE_ASC="OG Title ascending"
COM_MOKOOG_HEADING_OG_TITLE_DESC="OG Title descending"
COM_MOKOOG_HEADING_MODIFIED_ASC="Modified ascending"
COM_MOKOOG_HEADING_MODIFIED_DESC="Modified descending"
COM_MOKOOG_TOOLBAR_BATCH_GENERATE="Batch Generate"
COM_MOKOOG_BATCH_TITLE="Batch OG Tag Generation"
COM_MOKOOG_BATCH_COUNTING="Counting articles without OG tags..."
COM_MOKOOG_BATCH_NONE="All articles already have OG tags."
COM_MOKOOG_BATCH_FOUND="articles found without OG tags."
COM_MOKOOG_BATCH_PROCESSED="processed"
COM_MOKOOG_BATCH_COMPLETE="Batch generation complete!"
COM_MOKOOG_BATCH_ERROR="Error:"
COM_MOKOOG_TOOLBAR_EXPORT="Export CSV"
COM_MOKOOG_TOOLBAR_IMPORT="Import CSV"
COM_MOKOOG_IMPORT_NO_FILE="No CSV file was uploaded."
COM_MOKOOG_IMPORT_INVALID_TYPE="Invalid file type. Please upload a .csv file."
COM_MOKOOG_IMPORT_FILE_TOO_LARGE="File is too large. Maximum allowed size is %s."
COM_MOKOOG_IMPORT_READ_ERROR="Could not read the uploaded CSV file."
COM_MOKOOG_IMPORT_RESULT="Import complete: %d created, %d updated, %d skipped."
@@ -1,6 +1,6 @@
; MokoOpenGraph - Component System Language File
; MokoJoomOpenGraph - Component System Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
COM_MOKOOG="MokoOpenGraph"
COM_MOKOOG="MokoJoomOpenGraph"
COM_MOKOOG_DESCRIPTION="Manage Open Graph and social sharing tags for all your content. View, edit, and batch-process OG metadata."
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,59 @@
; MokoJoomOpenGraph - Component Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
COM_MOKOOG="MokoJoomOpenGraph"
COM_MOKOOG_TAGS_TITLE="MokoJoomOpenGraph - Tag Manager"
COM_MOKOOG_SUBMENU_TAGS="Tags"
COM_MOKOOG_NO_TAGS="No Open Graph tags have been created yet. Tags are created automatically when you edit articles or menu items."
COM_MOKOOG_TABLE_CAPTION="Table of Open Graph tags"
COM_MOKOOG_AUTO_GENERATED="auto-generated"
COM_MOKOOG_HEADING_CONTENT_TYPE="Content Type"
COM_MOKOOG_HEADING_CONTENT_ID="Content ID"
COM_MOKOOG_HEADING_OG_TITLE="OG Title"
COM_MOKOOG_HEADING_IMAGE="Image"
COM_MOKOOG_HEADING_SEO="SEO"
COM_MOKOOG_HEADING_DEBUG="Debug"
COM_MOKOOG_HEADING_MODIFIED="Modified"
COM_MOKOOG_SEO_OK="OK"
COM_MOKOOG_SEO_MISSING_DESC="No meta description"
COM_MOKOOG_SEO_TITLE_LONG="SEO title too long"
COM_MOKOOG_SEO_NOINDEX="noindex"
COM_MOKOOG_FIELD_CONTENT_TYPE="Content Type"
COM_MOKOOG_FIELD_CONTENT_ID="Content ID"
COM_MOKOOG_FIELD_OG_TITLE="OG Title"
COM_MOKOOG_FIELD_OG_TITLE_DESC="Custom title for social sharing."
COM_MOKOOG_FIELD_OG_DESCRIPTION="OG Description"
COM_MOKOOG_FIELD_OG_DESCRIPTION_DESC="Custom description for social sharing."
COM_MOKOOG_FIELD_OG_IMAGE="OG Image"
COM_MOKOOG_FIELD_OG_IMAGE_DESC="Custom image for social sharing."
COM_MOKOOG_FIELD_OG_TYPE="OG Type"
COM_MOKOOG_FIELD_OG_TYPE_DESC="The Open Graph content type."
COM_MOKOOG_FILTER_SEARCH="Search OG titles"
COM_MOKOOG_FILTER_CONTENT_TYPE="Content Type"
COM_MOKOOG_FILTER_SELECT_TYPE="- Select Type -"
COM_MOKOOG_HEADING_OG_TITLE_ASC="OG Title ascending"
COM_MOKOOG_HEADING_OG_TITLE_DESC="OG Title descending"
COM_MOKOOG_HEADING_MODIFIED_ASC="Modified ascending"
COM_MOKOOG_HEADING_MODIFIED_DESC="Modified descending"
COM_MOKOOG_TOOLBAR_BATCH_GENERATE="Batch Generate"
COM_MOKOOG_BATCH_TITLE="Batch OG Tag Generation"
COM_MOKOOG_BATCH_COUNTING="Counting articles without OG tags..."
COM_MOKOOG_BATCH_NONE="All articles already have OG tags."
COM_MOKOOG_BATCH_FOUND="articles found without OG tags."
COM_MOKOOG_BATCH_PROCESSED="processed"
COM_MOKOOG_BATCH_COMPLETE="Batch generation complete!"
COM_MOKOOG_BATCH_ERROR="Error:"
COM_MOKOOG_TOOLBAR_EXPORT="Export CSV"
COM_MOKOOG_TOOLBAR_IMPORT="Import CSV"
COM_MOKOOG_IMPORT_NO_FILE="No CSV file was uploaded."
COM_MOKOOG_IMPORT_INVALID_TYPE="Invalid file type. Please upload a .csv file."
COM_MOKOOG_IMPORT_FILE_TOO_LARGE="File is too large. Maximum allowed size is %s."
COM_MOKOOG_IMPORT_READ_ERROR="Could not read the uploaded CSV file."
COM_MOKOOG_IMPORT_RESULT="Import complete: %d created, %d updated, %d skipped."
@@ -1,6 +1,6 @@
; MokoOpenGraph - Component System Language File
; MokoJoomOpenGraph - Component System Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
COM_MOKOOG="MokoOpenGraph"
COM_MOKOOG="MokoJoomOpenGraph"
COM_MOKOOG_DESCRIPTION="Manage Open Graph and social sharing tags for all your content. View, edit, and batch-process OG metadata."
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -8,7 +8,7 @@
-->
<extension type="component" method="upgrade">
<name>com_mokoog</name>
<version>01.01.00</version>
<version>01.01.01</version>
<creationDate>2026-05-23</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
@@ -42,6 +42,7 @@
<filename>provider.php</filename>
</files>
<files folder="src">
<folder>ContentType</folder>
<folder>Controller</folder>
<folder>Extension</folder>
<folder>Model</folder>
@@ -68,4 +69,10 @@
<menu link="option=com_mokoog&amp;view=tags">COM_MOKOOG_SUBMENU_TAGS</menu>
</submenu>
</administration>
<api>
<files folder="api">
<folder>src</folder>
</files>
</api>
</extension>
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -23,7 +23,7 @@ class Com_MokoOGInstallerScript
*/
public function install(InstallerAdapter $parent): void
{
echo '<p>MokoOpenGraph component installed successfully.</p>';
echo '<p>MokoJoomOpenGraph component installed successfully.</p>';
}
/**
@@ -35,6 +35,6 @@ class Com_MokoOGInstallerScript
*/
public function update(InstallerAdapter $parent): void
{
echo '<p>MokoOpenGraph component updated successfully.</p>';
echo '<p>MokoJoomOpenGraph component updated successfully.</p>';
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,5 +1,5 @@
--
-- MokoOpenGraph - Database Schema
-- MokoJoomOpenGraph - Database Schema
-- Copyright (C) 2026 Moko Consulting. All rights reserved.
-- License: GPL-3.0-or-later
--
@@ -12,10 +12,15 @@ CREATE TABLE IF NOT EXISTS `#__mokoog_tags` (
`og_description` TEXT NOT NULL,
`og_image` VARCHAR(512) NOT NULL DEFAULT '',
`og_type` VARCHAR(50) NOT NULL DEFAULT 'article',
`seo_title` VARCHAR(70) NOT NULL DEFAULT '',
`meta_description` VARCHAR(200) NOT NULL DEFAULT '',
`robots` VARCHAR(100) NOT NULL DEFAULT '',
`canonical_url` VARCHAR(512) NOT NULL DEFAULT '',
`language` CHAR(7) NOT NULL DEFAULT '*',
`published` TINYINT(1) NOT NULL DEFAULT 1,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_content` (`content_type`, `content_id`),
UNIQUE KEY `idx_content_lang` (`content_type`, `content_id`, `language`),
KEY `idx_published` (`published`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@@ -1,5 +1,5 @@
--
-- MokoOpenGraph - Uninstall
-- MokoJoomOpenGraph - Uninstall
--
DROP TABLE IF EXISTS `#__mokoog_tags`;
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,9 @@
--
-- MokoJoomOpenGraph 01.01.00 — Add SEO meta management columns
--
ALTER TABLE `#__mokoog_tags`
ADD COLUMN `seo_title` VARCHAR(70) NOT NULL DEFAULT '' AFTER `og_type`,
ADD COLUMN `meta_description` VARCHAR(200) NOT NULL DEFAULT '' AFTER `seo_title`,
ADD COLUMN `robots` VARCHAR(100) NOT NULL DEFAULT '' AFTER `meta_description`,
ADD COLUMN `canonical_url` VARCHAR(512) NOT NULL DEFAULT '' AFTER `robots`;
@@ -0,0 +1,10 @@
--
-- MokoJoomOpenGraph 01.02.00 — Add multilingual OG tag support
--
ALTER TABLE `#__mokoog_tags`
ADD COLUMN `language` CHAR(7) NOT NULL DEFAULT '*' AFTER `canonical_url`;
ALTER TABLE `#__mokoog_tags`
DROP INDEX `idx_content`,
ADD UNIQUE KEY `idx_content_lang` (`content_type`, `content_id`, `language`);
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,182 @@
<?php
/**
* @package MokoSuiteOpenGraph
* @subpackage com_mokoog
* @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
*/
namespace Joomla\Component\MokoOG\Administrator\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Session\Session;
class BatchController extends BaseController
{
/**
* Count the total articles eligible for batch generation.
*
* @return void
*/
public function count(): void
{
Session::checkToken('get') || jexit(Text::_('JINVALID_TOKEN'));
if (!Factory::getApplication()->getIdentity()->authorise('core.create', 'com_mokoog')) {
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
}
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__content', 'c'))
->leftJoin(
$db->quoteName('#__mokoog_tags', 't')
. ' ON ' . $db->quoteName('t.content_type') . ' = ' . $db->quote('com_content')
. ' AND ' . $db->quoteName('t.content_id') . ' = ' . $db->quoteName('c.id')
)
->where($db->quoteName('c.state') . ' = 1')
->where($db->quoteName('t.id') . ' IS NULL');
$db->setQuery($query);
$total = (int) $db->loadResult();
echo new JsonResponse(['total' => $total]);
Factory::getApplication()->close();
}
/**
* Process a chunk of articles for batch OG generation.
*
* @return void
*/
public function process(): void
{
Session::checkToken('get') || jexit(Text::_('JINVALID_TOKEN'));
if (!Factory::getApplication()->getIdentity()->authorise('core.create', 'com_mokoog')) {
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
}
$app = Factory::getApplication();
$limit = min($app->getInput()->getInt('limit', 50), 200);
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName([
'c.id', 'c.title', 'c.metadesc', 'c.introtext', 'c.fulltext', 'c.images',
]))
->from($db->quoteName('#__content', 'c'))
->leftJoin(
$db->quoteName('#__mokoog_tags', 't')
. ' ON ' . $db->quoteName('t.content_type') . ' = ' . $db->quote('com_content')
. ' AND ' . $db->quoteName('t.content_id') . ' = ' . $db->quoteName('c.id')
)
->where($db->quoteName('c.state') . ' = 1')
->where($db->quoteName('t.id') . ' IS NULL')
->order($db->quoteName('c.id') . ' ASC');
// Always offset=0: processed articles now have #__mokoog_tags rows
// and are excluded by the LEFT JOIN ... IS NULL filter automatically.
$db->setQuery($query, 0, $limit);
$articles = $db->loadObjectList();
$created = 0;
$skipped = 0;
$now = Factory::getDate()->toSql();
foreach ($articles as $article) {
$ogTitle = $article->title;
$ogDescription = $this->extractDescription($article);
$ogImage = $this->extractImage($article);
$record = (object) [
'content_type' => 'com_content',
'content_id' => (int) $article->id,
'og_title' => $ogTitle,
'og_description' => $ogDescription,
'og_image' => $ogImage,
'og_type' => 'article',
'seo_title' => '',
'meta_description' => $article->metadesc ?: '',
'robots' => '',
'canonical_url' => '',
'language' => '*',
'published' => 1,
'created' => $now,
'modified' => $now,
];
try {
$db->insertObject('#__mokoog_tags', $record);
$created++;
} catch (\RuntimeException $e) {
$skipped++;
}
}
echo new JsonResponse([
'created' => $created,
]);
$app->close();
}
/**
* Extract a description from article content.
*
* @param object $article Article record
*
* @return string
*/
private function extractDescription(object $article): string
{
// Prefer meta description if set
if (!empty($article->metadesc)) {
return $article->metadesc;
}
// Fall back to intro text
$text = $article->introtext ?: $article->fulltext;
$text = strip_tags($text);
$text = trim(preg_replace('/\s+/', ' ', $text));
if (mb_strlen($text) > 160) {
$text = mb_substr($text, 0, 157) . '...';
}
return $text;
}
/**
* Extract the best image from article data.
*
* @param object $article Article record
*
* @return string
*/
private function extractImage(object $article): string
{
if (!empty($article->images)) {
$images = json_decode($article->images, true);
if (!empty($images['image_fulltext'])) {
return $images['image_fulltext'];
}
if (!empty($images['image_intro'])) {
return $images['image_intro'];
}
}
return '';
}
}
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -0,0 +1,255 @@
<?php
/**
* @package MokoSuiteOpenGraph
* @subpackage com_mokoog
* @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
*/
namespace Joomla\Component\MokoOG\Administrator\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Session\Session;
class ImportExportController extends BaseController
{
/**
* Maximum upload file size in bytes (2 MB).
*/
private const MAX_FILE_SIZE = 2 * 1024 * 1024;
/**
* Allowed content_type patterns for import.
*/
private const CONTENT_TYPE_PATTERN = '/^[a-z][a-z0-9_.]*$/';
/**
* Export all OG tags as CSV.
*
* @return void
*/
public function export(): void
{
Session::checkToken('get') || jexit(Text::_('JINVALID_TOKEN'));
if (!Factory::getApplication()->getIdentity()->authorise('core.manage', 'com_mokoog')) {
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
}
$app = Factory::getApplication();
$db = Factory::getDbo();
// Join with #__content to get article titles for reference
$query = $db->getQuery(true)
->select([
$db->quoteName('t.content_type'),
$db->quoteName('t.content_id'),
'COALESCE(' . $db->quoteName('c.title') . ', ' . $db->quote('') . ') AS ' . $db->quoteName('article_title'),
$db->quoteName('t.og_title'),
$db->quoteName('t.og_description'),
$db->quoteName('t.og_image'),
$db->quoteName('t.og_type'),
$db->quoteName('t.seo_title'),
$db->quoteName('t.meta_description'),
$db->quoteName('t.robots'),
$db->quoteName('t.canonical_url'),
$db->quoteName('t.language'),
])
->from($db->quoteName('#__mokoog_tags', 't'))
->leftJoin(
$db->quoteName('#__content', 'c')
. ' ON ' . $db->quoteName('t.content_type') . ' = ' . $db->quote('com_content')
. ' AND ' . $db->quoteName('t.content_id') . ' = ' . $db->quoteName('c.id')
)
->order($db->quoteName('t.content_type') . ', ' . $db->quoteName('t.content_id'));
$db->setQuery($query);
$rows = $db->loadAssocList();
// Send CSV headers
$app->setHeader('Content-Type', 'text/csv; charset=utf-8');
$app->setHeader('Content-Disposition', 'attachment; filename="mokoog_tags_export.csv"');
$app->sendHeaders();
$output = fopen('php://output', 'w');
// Header row
fputcsv($output, [
'content_type', 'content_id', 'article_title',
'og_title', 'og_description', 'og_image', 'og_type',
'seo_title', 'meta_description', 'robots', 'canonical_url',
'language',
]);
foreach ($rows as $row) {
fputcsv($output, $row);
}
fclose($output);
$app->close();
}
/**
* Import OG tags from uploaded CSV.
*
* @return void
*/
public function import(): void
{
Session::checkToken() || jexit(Text::_('JINVALID_TOKEN'));
$identity = Factory::getApplication()->getIdentity();
if (!$identity->authorise('core.create', 'com_mokoog') || !$identity->authorise('core.edit', 'com_mokoog')) {
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
}
$app = Factory::getApplication();
$input = $app->getInput();
$files = $input->files->get('jform', [], 'array');
if (empty($files['csv_file']['tmp_name'])) {
$app->enqueueMessage(Text::_('COM_MOKOOG_IMPORT_NO_FILE'), 'error');
$app->redirect('index.php?option=com_mokoog&view=tags');
return;
}
$csvFile = $files['csv_file'];
// Validate file extension
$ext = strtolower(pathinfo($csvFile['name'] ?? '', PATHINFO_EXTENSION));
if ($ext !== 'csv') {
$app->enqueueMessage(Text::_('COM_MOKOOG_IMPORT_INVALID_TYPE'), 'error');
$app->redirect('index.php?option=com_mokoog&view=tags');
return;
}
// Validate MIME type
$allowedMimes = ['text/csv', 'text/plain', 'application/csv', 'application/vnd.ms-excel'];
if (!empty($csvFile['type']) && !\in_array($csvFile['type'], $allowedMimes, true)) {
$app->enqueueMessage(Text::_('COM_MOKOOG_IMPORT_INVALID_TYPE'), 'error');
$app->redirect('index.php?option=com_mokoog&view=tags');
return;
}
// Validate file size
if (($csvFile['size'] ?? 0) > self::MAX_FILE_SIZE) {
$app->enqueueMessage(Text::sprintf('COM_MOKOOG_IMPORT_FILE_TOO_LARGE', '2 MB'), 'error');
$app->redirect('index.php?option=com_mokoog&view=tags');
return;
}
$tmpFile = $csvFile['tmp_name'];
$handle = fopen($tmpFile, 'r');
if (!$handle) {
$app->enqueueMessage(Text::_('COM_MOKOOG_IMPORT_READ_ERROR'), 'error');
$app->redirect('index.php?option=com_mokoog&view=tags');
return;
}
$db = Factory::getDbo();
$header = fgetcsv($handle);
$created = 0;
$updated = 0;
$skipped = 0;
$now = Factory::getDate()->toSql();
while (($row = fgetcsv($handle)) !== false) {
if (\count($row) < 7) {
$skipped++;
continue;
}
$contentType = trim($row[0]);
$contentId = (int) $row[1];
// $row[2] = article_title (informational, skip)
$ogTitle = trim($row[3] ?? '');
$ogDescription = trim($row[4] ?? '');
$ogImage = trim($row[5] ?? '');
$ogType = trim($row[6] ?? 'article');
$seoTitle = trim($row[7] ?? '');
$metaDesc = trim($row[8] ?? '');
$robots = trim($row[9] ?? '');
$canonicalUrl = trim($row[10] ?? '');
$language = trim($row[11] ?? '*');
// Validate language tag format (e.g., 'en-GB', '*')
if ($language !== '*' && !preg_match('/^[a-z]{2,3}-[A-Z]{2}$/', $language)) {
$language = '*';
}
if (empty($contentType) || $contentId <= 0) {
$skipped++;
continue;
}
// Validate content_type against allowed pattern
if (!preg_match(self::CONTENT_TYPE_PATTERN, $contentType)) {
$skipped++;
continue;
}
// Check for existing record (unique key includes language)
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__mokoog_tags'))
->where($db->quoteName('content_type') . ' = ' . $db->quote($contentType))
->where($db->quoteName('content_id') . ' = ' . $contentId)
->where($db->quoteName('language') . ' = ' . $db->quote($language));
$db->setQuery($query);
$existingId = $db->loadResult();
$record = (object) [
'content_type' => $contentType,
'content_id' => $contentId,
'og_title' => $ogTitle,
'og_description' => $ogDescription,
'og_image' => $ogImage,
'og_type' => $ogType,
'seo_title' => $seoTitle,
'meta_description' => $metaDesc,
'robots' => $robots,
'canonical_url' => $canonicalUrl,
'language' => $language,
'published' => 1,
'modified' => $now,
];
if ($existingId) {
$record->id = $existingId;
$db->updateObject('#__mokoog_tags', $record, 'id');
$updated++;
} else {
$record->created = $now;
$db->insertObject('#__mokoog_tags', $record);
$created++;
}
}
fclose($handle);
$app->enqueueMessage(
Text::sprintf('COM_MOKOOG_IMPORT_RESULT', $created, $updated, $skipped),
'success'
);
$app->redirect('index.php?option=com_mokoog&view=tags');
}
}
@@ -0,0 +1,33 @@
<?php
/**
* @package MokoSuiteOpenGraph
* @subpackage com_mokoog
* @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
*/
namespace Joomla\Component\MokoOG\Administrator\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
class TagsController extends AdminController
{
/**
* Proxy for getModel.
*
* @param string $name Model name
* @param string $prefix Model prefix
* @param array $config Configuration array
*
* @return BaseDatabaseModel
*/
public function getModel($name = 'Tag', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
return parent::getModel($name, $prefix, $config);
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,68 @@
<?php
/**
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @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
*/
namespace Joomla\Component\MokoOG\Administrator\Model;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
class TagModel extends AdminModel
{
/**
* Get the form for the item.
*
* @param array $data Form data
* @param bool $loadData Load data from state
*
* @return \Joomla\CMS\Form\Form|false
*/
public function getForm($data = [], $loadData = true)
{
$form = $this->loadForm(
'com_mokoog.tag',
'tag',
['control' => 'jform', 'load_data' => $loadData]
);
return $form ?: false;
}
/**
* Load the form data.
*
* @return object
*/
protected function loadFormData(): object
{
$data = Factory::getApplication()->getUserState('com_mokoog.edit.tag.data', []);
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
/**
* Get the table class name.
*
* @param string $name Table name
* @param string $prefix Table prefix
* @param array $options Table options
*
* @return \Joomla\CMS\Table\Table
*/
public function getTable($name = 'Tag', $prefix = 'Administrator', $options = [])
{
return parent::getTable($name, $prefix, $options);
}
}
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,107 @@
<?php
/**
* @package MokoSuiteOpenGraph
* @subpackage com_mokoog
* @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
*/
namespace Joomla\Component\MokoOG\Administrator\Table;
defined('_JEXEC') or die;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
class TagTable extends Table
{
/**
* Constructor.
*
* @param DatabaseDriver $db Database driver instance
*/
public function __construct(DatabaseDriver $db)
{
parent::__construct('#__mokoog_tags', 'id', $db);
}
/**
* Perform checks before store.
*
* @return bool
*/
private const VALID_OG_TYPES = [
'article', 'website', 'product', 'profile', 'book', 'music.song',
'music.album', 'video.movie', 'video.episode', 'video.other',
];
private const VALID_ROBOTS = [
'index', 'noindex', 'follow', 'nofollow', 'none', 'noarchive',
'nosnippet', 'noimageindex', 'max-snippet', 'max-image-preview',
];
public function check(): bool
{
if (empty($this->content_type)) {
$this->setError('Content type is required.');
return false;
}
if (!preg_match('/^[a-z][a-z0-9_.]*$/', $this->content_type)) {
$this->setError('Content type contains invalid characters.');
return false;
}
if (empty($this->content_id)) {
$this->setError('Content ID is required.');
return false;
}
// Validate og_type against known values
if (!empty($this->og_type) && !\in_array($this->og_type, self::VALID_OG_TYPES, true)) {
$this->og_type = 'article';
}
// Truncate fields to schema max lengths
if (mb_strlen($this->og_title ?? '') > 255) {
$this->og_title = mb_substr($this->og_title, 0, 255);
}
if (mb_strlen($this->seo_title ?? '') > 70) {
$this->seo_title = mb_substr($this->seo_title, 0, 70);
}
if (mb_strlen($this->meta_description ?? '') > 200) {
$this->meta_description = mb_substr($this->meta_description, 0, 200);
}
// Validate canonical_url format if non-empty
if (!empty($this->canonical_url) && !filter_var($this->canonical_url, FILTER_VALIDATE_URL)) {
$this->canonical_url = '';
}
// Validate robots directives
if (!empty($this->robots)) {
$parts = array_map('trim', explode(',', strtolower($this->robots)));
$valid = array_filter($parts, function ($part) {
// Allow directives with values like "max-snippet:-1"
$directive = explode(':', $part)[0];
return \in_array($directive, self::VALID_ROBOTS, true);
});
$this->robots = $valid ? implode(', ', $valid) : '';
}
// Default language to '*' if not set
if (empty($this->language)) {
$this->language = '*';
}
return true;
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -39,6 +39,20 @@ class HtmlView extends BaseHtmlView
*/
protected $state;
/**
* The filter form.
*
* @var \Joomla\CMS\Form\Form|null
*/
public $filterForm;
/**
* The active filters.
*
* @var array
*/
public $activeFilters = [];
/**
* Display the view.
*
@@ -48,9 +62,11 @@ class HtmlView extends BaseHtmlView
*/
public function display($tpl = null): void
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$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();
@@ -65,6 +81,8 @@ class HtmlView extends BaseHtmlView
protected function addToolbar(): void
{
ToolbarHelper::title(Text::_('COM_MOKOOG_TAGS_TITLE'), 'bookmark');
ToolbarHelper::custom('batch.generate', 'refresh', '', 'COM_MOKOOG_TOOLBAR_BATCH_GENERATE', false);
ToolbarHelper::custom('importexport.export', 'download', '', 'COM_MOKOOG_TOOLBAR_EXPORT', false);
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'tags.delete');
ToolbarHelper::preferences('com_mokoog');
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,243 @@
<?php
/**
* @package MokoJoomOpenGraph
* @subpackage com_mokoog
* @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
*/
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\CMS\Uri\Uri;
use Joomla\CMS\Session\Session;
/** @var \Joomla\Component\MokoOG\Administrator\View\Tags\HtmlView $this */
$token = Session::getFormToken();
?>
<form action="<?php echo Route::_('index.php?option=com_mokoog&view=tags'); ?>" 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::_('COM_MOKOOG_NO_TAGS'); ?>
</div>
<?php else : ?>
<table class="table" id="tagList">
<caption class="visually-hidden">
<?php echo Text::_('COM_MOKOOG_TABLE_CAPTION'); ?>
</caption>
<thead>
<tr>
<td class="w-1 text-center">
<?php echo HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col">
<?php echo Text::_('COM_MOKOOG_HEADING_CONTENT_TYPE'); ?>
</th>
<th scope="col">
<?php echo Text::_('COM_MOKOOG_HEADING_CONTENT_ID'); ?>
</th>
<th scope="col">
<?php echo Text::_('COM_MOKOOG_HEADING_OG_TITLE'); ?>
</th>
<th scope="col" class="w-10">
<?php echo Text::_('COM_MOKOOG_HEADING_IMAGE'); ?>
</th>
<th scope="col" class="w-10">
<?php echo Text::_('COM_MOKOOG_HEADING_SEO'); ?>
</th>
<th scope="col" class="w-10">
<?php echo Text::_('JSTATUS'); ?>
</th>
<th scope="col" class="w-10">
<?php echo Text::_('COM_MOKOOG_HEADING_DEBUG'); ?>
</th>
<th scope="col" class="w-10">
<?php echo Text::_('COM_MOKOOG_HEADING_MODIFIED'); ?>
</th>
<th scope="col" class="w-5">
<?php echo Text::_('JGRID_HEADING_ID'); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<tr>
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
</td>
<td>
<?php echo $this->escape($item->content_type); ?>
</td>
<td>
<?php echo (int) $item->content_id; ?>
</td>
<td>
<?php echo $this->escape($item->og_title ?: '(' . Text::_('COM_MOKOOG_AUTO_GENERATED') . ')'); ?>
</td>
<td>
<?php if ($item->og_image) : ?>
<span class="icon-image" aria-hidden="true" title="<?php echo $this->escape($item->og_image); ?>"></span>
<?php else : ?>
<span class="icon-minus-circle text-muted" aria-hidden="true"></span>
<?php endif; ?>
</td>
<td>
<?php
$seoIssues = [];
if (empty($item->meta_description)) {
$seoIssues[] = Text::_('COM_MOKOOG_SEO_MISSING_DESC');
}
if (!empty($item->seo_title) && \strlen($item->seo_title) > 60) {
$seoIssues[] = Text::_('COM_MOKOOG_SEO_TITLE_LONG');
}
if (!empty($item->robots) && str_contains($item->robots, 'noindex')) {
$seoIssues[] = Text::_('COM_MOKOOG_SEO_NOINDEX');
}
if (empty($seoIssues)) : ?>
<span class="badge bg-success"><?php echo Text::_('COM_MOKOOG_SEO_OK'); ?></span>
<?php else : ?>
<?php foreach ($seoIssues as $issue) : ?>
<span class="badge bg-warning text-dark"><?php echo $issue; ?></span>
<?php endforeach; ?>
<?php endif; ?>
</td>
<td>
<?php echo $item->published ? Text::_('JPUBLISHED') : Text::_('JUNPUBLISHED'); ?>
</td>
<td class="mokoog-debug-links">
<?php
// Build frontend URL for this content item
if ($item->content_type === 'com_content') {
$debugUrl = Uri::root() . 'index.php?option=com_content&view=article&id=' . (int) $item->content_id;
} elseif ($item->content_type === 'menu') {
$debugUrl = Uri::root() . 'index.php?Itemid=' . (int) $item->content_id;
} elseif ($item->content_type === 'com_content.category') {
$debugUrl = Uri::root() . 'index.php?option=com_content&view=category&id=' . (int) $item->content_id;
} else {
$debugUrl = Uri::root();
}
?>
<a href="https://developers.facebook.com/tools/debug/?q=<?php echo urlencode($debugUrl); ?>" target="_blank" rel="noopener" title="Facebook Debugger" class="btn btn-sm btn-outline-primary">FB</a>
<a href="https://www.linkedin.com/post-inspector/inspect/<?php echo urlencode($debugUrl); ?>" target="_blank" rel="noopener" title="LinkedIn Inspector" class="btn btn-sm btn-outline-info">LI</a>
<a href="https://search.google.com/test/rich-results?url=<?php echo urlencode($debugUrl); ?>" target="_blank" rel="noopener" title="Google Rich Results" class="btn btn-sm btn-outline-success">G</a>
</td>
<td>
<?php echo HTMLHelper::_('date', $item->modified, Text::_('DATE_FORMAT_LC4')); ?>
</td>
<td>
<?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>
<!-- Batch Generation Progress -->
<div id="mokoog-batch-panel" style="display:none;" class="card mt-3">
<div class="card-body">
<h4><?php echo Text::_('COM_MOKOOG_BATCH_TITLE'); ?></h4>
<div class="progress mb-2">
<div id="mokoog-batch-bar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%">0%</div>
</div>
<p id="mokoog-batch-status"></p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Intercept the batch.generate toolbar button
var origSubmitbutton = Joomla.submitbutton;
Joomla.submitbutton = function(task) {
if (task === 'batch.generate') {
mokoogBatchGenerate();
return;
}
if (origSubmitbutton) {
origSubmitbutton(task);
}
};
function mokoogBatchGenerate() {
var panel = document.getElementById('mokoog-batch-panel');
var bar = document.getElementById('mokoog-batch-bar');
var status = document.getElementById('mokoog-batch-status');
var token = '<?php echo $token; ?>';
var chunkSize = 50;
panel.style.display = 'block';
status.textContent = '<?php echo Text::_('COM_MOKOOG_BATCH_COUNTING', true); ?>';
// Step 1: Count eligible articles
fetch('index.php?option=com_mokoog&task=batch.count&format=json&' + token + '=1')
.then(function(r) { return r.json(); })
.then(function(resp) {
var total = resp.data.total;
if (total === 0) {
bar.style.width = '100%';
bar.textContent = '100%';
bar.classList.remove('progress-bar-animated');
bar.classList.add('bg-success');
status.textContent = '<?php echo Text::_('COM_MOKOOG_BATCH_NONE', true); ?>';
return;
}
status.textContent = total + ' <?php echo Text::_('COM_MOKOOG_BATCH_FOUND', true); ?>';
processChunk(0, total, chunkSize, token, bar, status);
})
.catch(function(err) {
status.textContent = '<?php echo Text::_('COM_MOKOOG_BATCH_ERROR', true); ?> ' + err.message;
});
}
function processChunk(processed, total, chunkSize, token, bar, status) {
// Always offset=0: processed items are excluded by the IS NULL filter
fetch('index.php?option=com_mokoog&task=batch.process&format=json&limit=' + chunkSize + '&' + token + '=1')
.then(function(r) { return r.json(); })
.then(function(resp) {
processed += resp.data.created;
var pct = Math.min(100, Math.round((processed / total) * 100));
bar.style.width = pct + '%';
bar.textContent = pct + '%';
status.textContent = processed + ' / ' + total + ' <?php echo Text::_('COM_MOKOOG_BATCH_PROCESSED', true); ?>';
if (resp.data.created > 0 && processed < total) {
processChunk(processed, total, chunkSize, token, bar, status);
} else {
bar.classList.remove('progress-bar-animated');
bar.classList.add('bg-success');
status.textContent = '<?php echo Text::_('COM_MOKOOG_BATCH_COMPLETE', true); ?> ' + processed + ' articles.';
setTimeout(function() { location.reload(); }, 2000);
}
})
.catch(function(err) {
status.textContent = '<?php echo Text::_('COM_MOKOOG_BATCH_ERROR', true); ?> ' + err.message;
});
}
});
</script>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
+1
View File
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -50,5 +50,48 @@
<option value="video.other">Video</option>
</field>
</fieldset>
<fieldset name="mokoog_seo" label="PLG_CONTENT_MOKOOG_FIELDSET_SEO_LABEL"
description="PLG_CONTENT_MOKOOG_FIELDSET_SEO_DESC">
<field
name="seo_title"
type="text"
label="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE"
description="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE_DESC"
filter="string"
maxlength="70"
/>
<field
name="meta_description"
type="textarea"
label="PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION"
description="PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION_DESC"
filter="string"
rows="3"
maxlength="200"
/>
<field
name="robots"
type="list"
label="PLG_CONTENT_MOKOOG_FIELD_ROBOTS"
description="PLG_CONTENT_MOKOOG_FIELD_ROBOTS_DESC"
default=""
multiple="true"
>
<option value="">PLG_CONTENT_MOKOOG_ROBOTS_DEFAULT</option>
<option value="noindex">noindex</option>
<option value="nofollow">nofollow</option>
<option value="nosnippet">nosnippet</option>
<option value="noarchive">noarchive</option>
<option value="noimageindex">noimageindex</option>
</field>
<field
name="canonical_url"
type="url"
label="PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL"
description="PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL_DESC"
filter="url"
validate="url"
/>
</fieldset>
</fields>
</form>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,28 @@
; MokoJoomOpenGraph - Content Plugin Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PLG_CONTENT_MOKOOG_FIELDSET_LABEL="Open Graph / Social Sharing"
PLG_CONTENT_MOKOOG_FIELDSET_DESC="Configure how this content appears when shared on social media."
PLG_CONTENT_MOKOOG_FIELD_OG_TITLE="OG Title"
PLG_CONTENT_MOKOOG_FIELD_OG_TITLE_DESC="Custom title for social sharing. Leave blank to use the article title."
PLG_CONTENT_MOKOOG_FIELD_OG_DESCRIPTION="OG Description"
PLG_CONTENT_MOKOOG_FIELD_OG_DESCRIPTION_DESC="Custom description for social sharing. Leave blank to auto-generate from content."
PLG_CONTENT_MOKOOG_FIELD_OG_IMAGE="OG Image"
PLG_CONTENT_MOKOOG_FIELD_OG_IMAGE_DESC="Custom image for social sharing. Recommended: 1200x630px. Leave blank to use the article image."
PLG_CONTENT_MOKOOG_FIELD_OG_TYPE="OG Type"
PLG_CONTENT_MOKOOG_FIELD_OG_TYPE_DESC="The Open Graph content type for this page."
PLG_CONTENT_MOKOOG_FIELDSET_SEO_LABEL="SEO Meta Tags"
PLG_CONTENT_MOKOOG_FIELDSET_SEO_DESC="Control search engine meta tags for this page."
PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE="SEO Title"
PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE_DESC="Custom <title> tag. 50-60 characters recommended. Leave blank to use the default page title."
PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION="Meta Description"
PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION_DESC="Custom meta description. 150-160 characters recommended. Leave blank to use the default."
PLG_CONTENT_MOKOOG_FIELD_ROBOTS="Robots Directive"
PLG_CONTENT_MOKOOG_FIELD_ROBOTS_DESC="Search engine indexing directives for this page. Leave blank for default (index, follow)."
PLG_CONTENT_MOKOOG_ROBOTS_DEFAULT="- Use default (index, follow) -"
PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL="Canonical URL"
PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL_DESC="Override the canonical URL for this page. Leave blank to use the current URL."
@@ -1,6 +1,6 @@
; MokoOpenGraph - Content Plugin System Language File
; MokoJoomOpenGraph - Content Plugin System Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PLG_CONTENT_MOKOOG="Content - MokoOpenGraph"
PLG_CONTENT_MOKOOG="Content - MokoJoomOpenGraph"
PLG_CONTENT_MOKOOG_DESCRIPTION="Adds Open Graph fields to article and menu item edit forms for per-page social sharing control."
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,28 @@
; MokoJoomOpenGraph - Content Plugin Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PLG_CONTENT_MOKOOG_FIELDSET_LABEL="Open Graph / Social Sharing"
PLG_CONTENT_MOKOOG_FIELDSET_DESC="Configure how this content appears when shared on social media."
PLG_CONTENT_MOKOOG_FIELD_OG_TITLE="OG Title"
PLG_CONTENT_MOKOOG_FIELD_OG_TITLE_DESC="Custom title for social sharing. Leave blank to use the article title."
PLG_CONTENT_MOKOOG_FIELD_OG_DESCRIPTION="OG Description"
PLG_CONTENT_MOKOOG_FIELD_OG_DESCRIPTION_DESC="Custom description for social sharing. Leave blank to auto-generate from content."
PLG_CONTENT_MOKOOG_FIELD_OG_IMAGE="OG Image"
PLG_CONTENT_MOKOOG_FIELD_OG_IMAGE_DESC="Custom image for social sharing. Recommended: 1200x630px. Leave blank to use the article image."
PLG_CONTENT_MOKOOG_FIELD_OG_TYPE="OG Type"
PLG_CONTENT_MOKOOG_FIELD_OG_TYPE_DESC="The Open Graph content type for this page."
PLG_CONTENT_MOKOOG_FIELDSET_SEO_LABEL="SEO Meta Tags"
PLG_CONTENT_MOKOOG_FIELDSET_SEO_DESC="Control search engine meta tags for this page."
PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE="SEO Title"
PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE_DESC="Custom <title> tag. 50-60 characters recommended. Leave blank to use the default page title."
PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION="Meta Description"
PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION_DESC="Custom meta description. 150-160 characters recommended. Leave blank to use the default."
PLG_CONTENT_MOKOOG_FIELD_ROBOTS="Robots Directive"
PLG_CONTENT_MOKOOG_FIELD_ROBOTS_DESC="Search engine indexing directives for this page. Leave blank for default (index, follow)."
PLG_CONTENT_MOKOOG_ROBOTS_DEFAULT="- Use default (index, follow) -"
PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL="Canonical URL"
PLG_CONTENT_MOKOOG_FIELD_CANONICAL_URL_DESC="Override the canonical URL for this page. Leave blank to use the current URL."
@@ -1,6 +1,6 @@
; MokoOpenGraph - Content Plugin System Language File
; MokoJoomOpenGraph - Content Plugin System Language File
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PLG_CONTENT_MOKOOG="Content - MokoOpenGraph"
PLG_CONTENT_MOKOOG="Content - MokoJoomOpenGraph"
PLG_CONTENT_MOKOOG_DESCRIPTION="Adds Open Graph fields to article and menu item edit forms for per-page social sharing control."
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,104 @@
/**
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GPL-3.0-or-later
*/
.mokoog-preview-wrapper {
margin: 15px 0;
padding: 15px;
background: #f8f9fa;
border-radius: 8px;
border: 1px solid #dee2e6;
}
.mokoog-preview-heading {
margin: 0 0 12px;
font-size: 14px;
color: #666;
}
.mokoog-platform-label {
display: block;
color: #999;
text-transform: uppercase;
font-size: 11px;
font-weight: 600;
margin-top: 16px;
margin-bottom: 4px;
}
.mokoog-platform-label:first-of-type {
margin-top: 0;
}
.mokoog-card {
overflow: hidden;
max-width: 500px;
background: #fff;
}
.mokoog-card-fb {
border: 1px solid #ddd;
border-radius: 3px;
}
.mokoog-card-tw {
border: 1px solid #cfd9de;
border-radius: 16px;
}
.mokoog-card-img {
height: 260px;
background: #e4e6eb center / cover no-repeat;
}
.mokoog-card-body {
padding: 10px 12px;
border-top: 1px solid #ddd;
}
.mokoog-card-tw .mokoog-card-body {
border-top-color: #cfd9de;
}
.mokoog-card-domain {
font-size: 11px;
color: #65676b;
text-transform: uppercase;
}
.mokoog-card-tw .mokoog-card-domain {
font-size: 13px;
text-transform: none;
margin-top: 4px;
}
.mokoog-card-title {
font-size: 16px;
font-weight: 600;
color: #1d2129;
margin: 3px 0 2px;
line-height: 1.3;
}
.mokoog-card-tw .mokoog-card-title {
font-size: 15px;
font-weight: 700;
color: #0f1419;
}
.mokoog-card-desc {
font-size: 14px;
color: #65676b;
line-height: 1.4;
max-height: 2.8em;
overflow: hidden;
}
.mokoog-card-tw .mokoog-card-desc {
font-size: 15px;
color: #536471;
margin-top: 2px;
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,20 @@
{
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
"name": "plg_content_mokoog",
"version": "01.00.00",
"description": "MokoJoomOpenGraph Content Plugin Assets",
"license": "GPL-3.0-or-later",
"assets": [
{
"name": "plg_content_mokoog.preview",
"type": "style",
"uri": "plg_content_mokoog/css/preview.css"
},
{
"name": "plg_content_mokoog.preview",
"type": "script",
"uri": "plg_content_mokoog/js/preview.js",
"dependencies": ["core"]
}
]
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,170 @@
/**
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GPL-3.0-or-later
*
* Live social sharing preview for article/menu item editor.
*/
document.addEventListener('DOMContentLoaded', function () {
'use strict';
var fields = {
ogTitle: document.getElementById('jform_mokoog_og_title'),
ogDesc: document.getElementById('jform_mokoog_og_description'),
ogImage: document.getElementById('jform_mokoog_og_image'),
articleTitle: document.getElementById('jform_title'),
metaDesc: document.getElementById('jform_metadesc')
};
// Find the mokoog fieldset and insert preview after it
var fieldset = document.querySelector('[data-showon-id="mokoog"]') ||
document.getElementById('attrib-mokoog') ||
document.querySelector('fieldset.mokoog') ||
document.querySelector('[id*="mokoog"]');
if (!fieldset) {
return;
}
// Build preview DOM safely (no innerHTML with user data)
var preview = document.createElement('div');
preview.id = 'mokoog-preview';
var wrapper = document.createElement('div');
wrapper.className = 'mokoog-preview-wrapper';
var heading = document.createElement('h4');
heading.className = 'mokoog-preview-heading';
heading.textContent = 'Social Sharing Preview';
wrapper.appendChild(heading);
// Facebook preview card
var fbLabel = document.createElement('small');
fbLabel.className = 'mokoog-platform-label';
fbLabel.textContent = 'Facebook';
wrapper.appendChild(fbLabel);
var fbCard = document.createElement('div');
fbCard.className = 'mokoog-card mokoog-card-fb';
var fbImg = document.createElement('div');
fbImg.id = 'mokoog-fb-img';
fbImg.className = 'mokoog-card-img';
fbCard.appendChild(fbImg);
var fbBody = document.createElement('div');
fbBody.className = 'mokoog-card-body';
var fbDomain = document.createElement('div');
fbDomain.id = 'mokoog-fb-domain';
fbDomain.className = 'mokoog-card-domain';
fbBody.appendChild(fbDomain);
var fbTitle = document.createElement('div');
fbTitle.id = 'mokoog-fb-title';
fbTitle.className = 'mokoog-card-title';
fbBody.appendChild(fbTitle);
var fbDesc = document.createElement('div');
fbDesc.id = 'mokoog-fb-desc';
fbDesc.className = 'mokoog-card-desc';
fbBody.appendChild(fbDesc);
fbCard.appendChild(fbBody);
wrapper.appendChild(fbCard);
// Twitter preview card
var twLabel = document.createElement('small');
twLabel.className = 'mokoog-platform-label';
twLabel.textContent = 'Twitter / X';
wrapper.appendChild(twLabel);
var twCard = document.createElement('div');
twCard.className = 'mokoog-card mokoog-card-tw';
var twImg = document.createElement('div');
twImg.id = 'mokoog-tw-img';
twImg.className = 'mokoog-card-img';
twCard.appendChild(twImg);
var twBody = document.createElement('div');
twBody.className = 'mokoog-card-body';
var twTitle = document.createElement('div');
twTitle.id = 'mokoog-tw-title';
twTitle.className = 'mokoog-card-title';
twBody.appendChild(twTitle);
var twDesc = document.createElement('div');
twDesc.id = 'mokoog-tw-desc';
twDesc.className = 'mokoog-card-desc';
twBody.appendChild(twDesc);
var twDomain = document.createElement('div');
twDomain.id = 'mokoog-tw-domain';
twDomain.className = 'mokoog-card-domain';
twBody.appendChild(twDomain);
twCard.appendChild(twBody);
wrapper.appendChild(twCard);
preview.appendChild(wrapper);
fieldset.parentNode.insertBefore(preview, fieldset.nextSibling);
var domain = window.location.hostname;
function updatePreview() {
var title = (fields.ogTitle && fields.ogTitle.value) ||
(fields.articleTitle && fields.articleTitle.value) || 'Page Title';
var desc = (fields.ogDesc && fields.ogDesc.value) ||
(fields.metaDesc && fields.metaDesc.value) || 'Page description will appear here...';
var img = '';
if (fields.ogImage) {
img = fields.ogImage.value;
}
if (title.length > 65) title = title.substring(0, 62) + '...';
if (desc.length > 160) desc = desc.substring(0, 157) + '...';
// Facebook
document.getElementById('mokoog-fb-title').textContent = title;
document.getElementById('mokoog-fb-desc').textContent = desc;
document.getElementById('mokoog-fb-domain').textContent = domain;
var fbImgEl = document.getElementById('mokoog-fb-img');
if (img) {
fbImgEl.style.backgroundImage = 'url(' + encodeURI(img) + ')';
fbImgEl.style.display = '';
} else {
fbImgEl.style.display = 'none';
}
// Twitter
document.getElementById('mokoog-tw-title').textContent = title;
document.getElementById('mokoog-tw-desc').textContent = desc;
document.getElementById('mokoog-tw-domain').textContent = domain;
var twImgEl = document.getElementById('mokoog-tw-img');
if (img) {
twImgEl.style.backgroundImage = 'url(' + encodeURI(img) + ')';
twImgEl.style.display = '';
} else {
twImgEl.style.display = 'none';
}
}
Object.values(fields).forEach(function (el) {
if (el) {
el.addEventListener('input', updatePreview);
el.addEventListener('change', updatePreview);
}
});
if (fields.ogImage) {
var observer = new MutationObserver(updatePreview);
observer.observe(fields.ogImage, { attributes: true, attributeFilter: ['value'] });
}
updatePreview();
});
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @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
-->
<extension type="plugin" group="content" method="upgrade">
<name>Content - MokoOpenGraph</name>
<version>01.01.00</version>
<name>Content - MokoJoomOpenGraph</name>
<version>01.01.01</version>
<creationDate>2026-05-23</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
@@ -27,6 +27,12 @@
<folder>language</folder>
</files>
<media destination="plg_content_mokoog" folder="media">
<filename>joomla.asset.json</filename>
<folder>js</folder>
<folder>css</folder>
</media>
<languages>
<language tag="en-GB">language/en-GB/plg_content_mokoog.ini</language>
<language tag="en-GB">language/en-GB/plg_content_mokoog.sys.ini</language>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoOpenGraph
* @package MokoJoomOpenGraph
* @subpackage plg_content_mokoog
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
@@ -56,10 +56,11 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
$formName = $form->getName();
// Add OG fields to article and menu item edit forms
// Add OG fields to article, menu item, and category edit forms
$supportedForms = [
'com_content.article',
'com_menus.item',
'com_categories.categorycom_content',
];
if (!\in_array($formName, $supportedForms, true)) {
@@ -71,6 +72,12 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
Form::addFormPath($formPath);
$form->loadFile('mokoog', false);
// Load live preview assets
$wa = $this->getApplication()->getDocument()->getWebAssetManager();
$wa->getRegistry()->addRegistryFile('media/plg_content_mokoog/joomla.asset.json');
$wa->useStyle('plg_content_mokoog.preview');
$wa->useScript('plg_content_mokoog.preview');
// If editing an existing item, load saved OG data
$id = 0;
@@ -81,8 +88,14 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
}
if ($id > 0) {
$contentType = ($formName === 'com_menus.item') ? 'menu' : 'com_content';
$ogData = $this->loadOgData($contentType, $id);
$formTypeMap = [
'com_content.article' => 'com_content',
'com_menus.item' => 'menu',
'com_categories.categorycom_content' => 'com_content.category',
];
$contentType = $formTypeMap[$formName] ?? 'com_content';
$language = $this->getContentLanguage($data);
$ogData = $this->loadOgData($contentType, $id, $language);
if ($ogData) {
$form->bind(['mokoog' => (array) $ogData]);
@@ -102,8 +115,9 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
[$context, $article, $isNew] = array_values($event->getArguments());
$supportedContexts = [
'com_content.article' => 'com_content',
'com_menus.item' => 'menu',
'com_content.article' => 'com_content',
'com_menus.item' => 'menu',
'com_categories.categorycom_content' => 'com_content.category',
];
if (!isset($supportedContexts[$context])) {
@@ -119,6 +133,7 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
$contentType = $supportedContexts[$context];
$contentId = (int) $article->id;
$language = $this->getContentLanguage($article);
$input = $app->getInput();
$jform = $input->get('jform', [], 'array');
@@ -128,7 +143,7 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
return;
}
$this->saveOgData($contentType, $contentId, $ogData);
$this->saveOgData($contentType, $contentId, $ogData, $language);
}
/**
@@ -143,8 +158,9 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
[$context, $article] = array_values($event->getArguments());
$supportedContexts = [
'com_content.article' => 'com_content',
'com_menus.item' => 'menu',
'com_content.article' => 'com_content',
'com_menus.item' => 'menu',
'com_categories.categorycom_content' => 'com_content.category',
];
if (!isset($supportedContexts[$context])) {
@@ -165,23 +181,30 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
}
/**
* Load existing OG data for a content item.
* Load existing OG data for a content item, filtered by language.
*
* @param string $contentType Content type identifier
* @param int $contentId Content ID
* @param string $language Language tag (e.g. 'en-GB') or '*' for all
*
* @return object|null
*/
private function loadOgData(string $contentType, int $contentId): ?object
private function loadOgData(string $contentType, int $contentId, string $language = '*'): ?object
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(['og_title', 'og_description', 'og_image', 'og_type']))
->select($db->quoteName([
'og_title', 'og_description', 'og_image', 'og_type',
'seo_title', 'meta_description', 'robots', 'canonical_url',
]))
->from($db->quoteName('#__mokoog_tags'))
->where($db->quoteName('content_type') . ' = ' . $db->quote($contentType))
->where($db->quoteName('content_id') . ' = ' . $contentId);
->where($db->quoteName('content_id') . ' = ' . $contentId)
->where('(' . $db->quoteName('language') . ' = ' . $db->quote($language)
. ' OR ' . $db->quoteName('language') . ' = ' . $db->quote('*') . ')')
->order('CASE WHEN ' . $db->quoteName('language') . ' = ' . $db->quote('*') . ' THEN 1 ELSE 0 END ASC');
$db->setQuery($query);
$db->setQuery($query, 0, 1);
return $db->loadObject();
}
@@ -192,32 +215,46 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
* @param string $contentType Content type identifier
* @param int $contentId Content ID
* @param array $ogData OG field values
* @param string $language Language tag (e.g. 'en-GB') or '*' for all
*
* @return void
*/
private function saveOgData(string $contentType, int $contentId, array $ogData): void
private function saveOgData(string $contentType, int $contentId, array $ogData, string $language = '*'): void
{
$db = Factory::getDbo();
// Check if record exists
// Check if record exists for this content + language
$query = $db->getQuery(true)
->select('id')
->from($db->quoteName('#__mokoog_tags'))
->where($db->quoteName('content_type') . ' = ' . $db->quote($contentType))
->where($db->quoteName('content_id') . ' = ' . $contentId);
->where($db->quoteName('content_id') . ' = ' . $contentId)
->where($db->quoteName('language') . ' = ' . $db->quote($language));
$db->setQuery($query);
$existingId = $db->loadResult();
// Robots may come as array from multi-select, join with comma
$robots = $ogData['robots'] ?? '';
if (\is_array($robots)) {
$robots = implode(', ', array_filter($robots));
}
$record = (object) [
'content_type' => $contentType,
'content_id' => $contentId,
'og_title' => trim($ogData['og_title'] ?? ''),
'og_description' => trim($ogData['og_description'] ?? ''),
'og_image' => trim($ogData['og_image'] ?? ''),
'og_type' => trim($ogData['og_type'] ?? 'article'),
'published' => 1,
'modified' => Factory::getDate()->toSql(),
'content_type' => $contentType,
'content_id' => $contentId,
'language' => $language,
'og_title' => trim($ogData['og_title'] ?? ''),
'og_description' => trim($ogData['og_description'] ?? ''),
'og_image' => trim($ogData['og_image'] ?? ''),
'og_type' => trim($ogData['og_type'] ?? 'article'),
'seo_title' => trim($ogData['seo_title'] ?? ''),
'meta_description' => trim($ogData['meta_description'] ?? ''),
'robots' => trim($robots),
'canonical_url' => trim($ogData['canonical_url'] ?? ''),
'published' => 1,
'modified' => Factory::getDate()->toSql(),
];
if ($existingId) {
@@ -228,4 +265,24 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
$db->insertObject('#__mokoog_tags', $record);
}
}
/**
* Extract the language tag from content data.
*
* @param object|array $data Content data from form or article object
*
* @return string Language tag (e.g. 'en-GB') or '*' for all languages
*/
private function getContentLanguage($data): string
{
$language = '*';
if (\is_object($data) && isset($data->language)) {
$language = $data->language;
} elseif (\is_array($data) && isset($data['language'])) {
$language = $data['language'];
}
return !empty($language) ? $language : '*';
}
}

Some files were not shown because too many files have changed in this diff Show More