Include Omeka functions in tinyMCE plugin

I’m making a plugin for tinyMCE (it will let users build shortcodes to be inserted).

Everything is going well, except that I need my plugin to be able to access Omeka’s functions, so I can do things like list items and collections. I’m basing it on the existing “emotions” plugin, which uses a popup dialog, which in my case is a php file. How do I include all the Omeka stuff, including my theme’s custom.php?

Thanks in advance,
JK

I see from the /index.php page and the /admin/index.php that I can load bootstrap.php and then initialize the application. How do I do this in a “headless” way, so there’s no ui, just available functions?

This shows the home page…

require_once('../../../../../../../../bootstrap.php'); 

// Configure, initialize, and run the application.
$application = new Omeka_Application(APPLICATION_ENV);
$application->getBootstrap()->setOptions(array(
    'resources' => array(
        'theme' => array(
            'basePath' => THEME_DIR,
            'webBasePath' => WEB_THEME
        )
    )
));
$application->initialize()->run();

This apparently makes it be the “admin” chrome.

define('ADMIN', true);

require_once('../../../../../../../../bootstrap.php');

// Configure, initialize, and run the application.
$application = new Omeka_Application(APPLICATION_ENV);
$application->getBootstrap()->setOptions(array(
    'resources' => array(
        'theme' => array(
            'basePath' => THEME_DIR,
            'webBasePath' => WEB_THEME
        )
    )
));
// Set an admin flag to the front controller.
Zend_Controller_Front::getInstance()->setParam('admin', true);
$application->initialize()->run();

I found this file

/application/scripts/background.php

Seems like it’s meant to initialize Omeka without displaying templates.

But I can’t run it. I get errors that register_argc_argv is off. If I turn it on via php_flag register_argc_argv on in .htaccess, I get errors about

Undefined offset: 0 in /var/www/omeka/application/libraries/Zend/Console/Getopt.php on line 257