Reference Omeka Classic plugin

Hooks and Integration

Hooks

Each change fires an Omeka Classic plugin hook, after the file is written and its revision stored. Add them to your plugin's $_hooks:

Hook When Arguments
theme_file_editor_file_save A file was saved theme, path (in the theme), revision_id, user_id
theme_file_editor_file_rollback A file was rolled back theme, path, from_revision_id, new_revision_id, user_id
theme_file_editor_copy_to_theme A core or plugin view was copied into a theme theme, path (the new file), source (the view's path, such as plugins/SimplePages/views/public/page/show.php), user_id
theme_file_editor_copy_theme A theme was copied source, theme (the copy), user_id
theme_file_editor_delete_theme A theme copy was deleted theme, user_id
class MySitePlugin extends Omeka_Plugin_AbstractPlugin
{
    protected $_hooks = ['theme_file_editor_file_save'];

    public function hookThemeFileEditorFileSave($args)
    {
        // $args['theme'], $args['path'], $args['revision_id'], $args['user_id']
    }
}

The change has already happened when a hook runs: an exception thrown by a hook is written to Omeka's log and does not affect the change or what the editor reports.

Filter

Filter Value
theme_file_editor_roles ['super'] The roles allowed to use the editor. Add admin (or another role) to give it access; Super User is always allowed. See Security Model.

Audit Trail

Each change also fires audit_trail_log, which the Audit Trail plugin records with the user, address and time; nothing happens when it is not installed.

Change action resource_type detail data
Save theme_file.save theme_file Saved themes/my-theme/items/show.php theme, path, revision_id, size, summary, backup
Rollback theme_file.rollback theme_file Rolled back themes/my-theme/items/show.php to revision #12 theme, path, from_revision_id, new_revision_id
Copy to Theme theme_file.copy theme_file Copied application/views/scripts/items/show.php to themes/my-theme/items/show.php theme, path, source, replaced
Copy Theme theme.copy theme Copied the theme Overprint (overprint) to My Overprint (my-overprint) source, theme, title, files, bytes, skipped_links, options
Delete a copy theme.delete theme Deleted the theme copy My Overprint (my-overprint) theme, source
Delete a backup theme_file.delete_backup theme_file Deleted the backup themes/my-theme/items/show.php.20261027143000.bak theme, path

resource_id is always null: theme files are not Omeka records. File content is never logged.

Services

Other plugins can use the plugin's classes through ThemeFileEditor\Services:

Service
Services::browser() FileBrowser: themes, sources, listing, path checks, override rules, search
Services::catalog() ThemeCatalog: each theme's status and whether it is editable
Services::editor() FileEditor: read, save, roll back, copy to theme, copy theme, delete a copy or a backup (fires the hooks above)
Services::revisions() RevisionManager: create, list, compare, prune revisions
Services::syntax() SyntaxChecker: check(string $code): ?string

Refusals throw ThemeFileEditor\Exception\SecurityException (a RuntimeException).

Database table

CREATE TABLE `<prefix>theme_file_editor_revisions` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `theme` VARCHAR(128) NOT NULL,
    `relative_path` VARCHAR(512) NOT NULL,
    `content` MEDIUMTEXT NOT NULL,
    `user_id` INT UNSIGNED DEFAULT NULL,
    `created_at` DATETIME NOT NULL,
    `change_summary` VARCHAR(255) DEFAULT NULL,
    `checksum` CHAR(64) NOT NULL,
    `file_size` INT UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    KEY `theme_path` (`theme`, `relative_path`(191)),
    KEY `created_at` (`created_at`),
    KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

created_at is UTC; checksum is the SHA-256 of content; user_id has no foreign key, so revisions outlive their author's account.

Log in for Support