/**
  * Spin up the plugins and prepare the database.
  *
  * @return void.
  */
 public function setUpPlugin()
 {
     parent::setUp();
     $this->user = $this->db->getTable('User')->find(1);
     $this->_authenticateUser($this->user);
     $this->servicesTable = $this->db->getTable('NeatlineMapsService');
     $this->serversTable = $this->db->getTable('NeatlineMapsServer');
     // Set up Neatline WMS.
     $plugin_broker = get_plugin_broker();
     $this->_addHooksAndFilters($plugin_broker, 'NeatlineMaps');
     $plugin_helper = new Omeka_Test_Helper_Plugin();
     $plugin_helper->setUp('NeatlineMaps');
     $this->_dbHelper = Omeka_Test_Helper_Db::factory($this->core);
 }
 /**
  * Runs the import process.
  * 
  * @param array $args Required arguments to run the process.
  */
 public function run($args)
 {
     // Raise the memory limit.
     ini_set('memory_limit', '500M');
     // Add the before_insert_file hook during import if the required ZIP
     // library exists.
     if (class_exists('ZipArchive')) {
         get_plugin_broker()->addHook('before_save_file', 'ZoteroImportPlugin::beforeSaveFile', 'ZoteroImport');
     }
     // Set the arguments.
     $this->_libraryId = $args['libraryId'];
     $this->_libraryType = $args['libraryType'];
     $this->_libraryCollectionId = $args['libraryCollectionId'];
     $this->_privateKey = $args['privateKey'];
     $this->_collectionId = $args['collectionId'];
     $this->_zoteroImportId = $args['zoteroImportId'];
     // Set the Zotero client. Make up to 3 request attempts.
     $this->_client = new ZoteroApiClient_Service_Zotero($this->_privateKey, 3);
     $this->_import();
 }
Example #3
0
/**
 * Clear all implementations for a filter (or all filters).
 *
 * @package Omeka\Function\Plugin
 * @uses Omeka_Plugin_Broker::clearFilters()
 * @param string|null $name The name of the filter to clear. If null or omitted,
 *  all filters will be cleared.
 */
function clear_filters($filterName = null)
{
    if ($pluginBroker = get_plugin_broker()) {
        $pluginBroker->clearFilters($filterName);
    }
}
Example #4
0
 public function testFireHookMakeRecordNotPublicNotFeatured()
 {
     $item = new Item();
     $mixin = new Mixin_PublicFeatured($item);
     $this->assertFalse($mixin->isPublic());
     $this->assertFalse($mixin->isFeatured());
     $item->public = true;
     $item->featured = true;
     $item->save();
     $this->assertTrue($mixin->isPublic());
     $this->assertTrue($mixin->isFeatured());
     $mockA = $this->getMock('stdClass', array('myCallBackA'));
     $mockA->expects($this->once())->method('myCallBackA')->will($this->returnValue(true));
     $hookName = 'make_item_not_public';
     $callback = array($mockA, 'myCallBackA');
     $plugin = '__global__';
     get_plugin_broker()->addHook($hookName, $callback, $plugin);
     $mockB = $this->getMock('stdClass', array('myCallBackB'));
     $mockB->expects($this->once())->method('myCallBackB')->will($this->returnValue(true));
     $hookName = 'make_item_not_featured';
     $callback = array($mockB, 'myCallBackB');
     $plugin = '__global__';
     get_plugin_broker()->addHook($hookName, $callback, $plugin);
     $this->assertEquals(1, $item->public);
     $this->assertEquals(1, $item->featured);
     $item->public = false;
     $item->featured = false;
     $item->save();
 }
Example #5
0
 /**
  * Look for a 'custom.php' script in all script paths and include the file if it exists.
  * 
  * @internal This must 'include' (as opposed to 'require_once') the script because
  * it typically contains executable code that modifies global state.  These
  * scripts need to be loaded only once per request, but multiple times in
  * the test environment.  Hence the flag for making sure that it runs only
  * once per View instance.
  * @return void
  */
 private function _loadCustomThemeScripts()
 {
     if ($this->_customScriptsLoaded) {
         return;
     }
     $pluginBroker = get_plugin_broker();
     if ($pluginBroker) {
         $tmpPluginDir = $pluginBroker->getCurrentPluginDirName();
         $newPluginDir = $pluginBroker->setCurrentPluginDirName(self::THEME_HOOK_NAMESPACE);
     }
     foreach ($this->getScriptPaths() as $path) {
         $customScriptPath = $path . 'custom.php';
         if (file_exists($customScriptPath)) {
             include $customScriptPath;
         }
     }
     if ($pluginBroker) {
         $pluginBroker->setCurrentPluginDirName($tmpPluginDir);
     }
     $this->_customScriptsLoaded = true;
 }
Example #6
0
 private function _getPluginBroker()
 {
     return get_plugin_broker();
 }