/**
  * Installs the plugin.
  */
 public function hookInstall()
 {
     // Load elements to add.
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'elements.php';
     $elementSetName = $elementSetMetadata['name'];
     $elementSet = get_record('ElementSet', array('name' => $elementSetName));
     // Don't install if an element set named "Streaming Video" already exists.
     if ($elementSet) {
         throw new Omeka_Plugin_Exception('An element set by the name "' . $elementSetName . '" already exists.' . ' ' . 'You must delete that element set before to install this plugin.');
     }
     insert_element_set($elementSetMetadata, $elements);
     // Prepare element ids for javascript.
     $elementIds = array();
     $elementsTable = $this->_db->getTable('Element');
     $element = $elementsTable->findByElementSetNameAndElementName('Dublin Core', 'Title');
     $elementIds['Dublin Core:Title'] = $element->id;
     $element = $elementsTable->findByElementSetNameAndElementName('Dublin Core', 'Description');
     $elementIds['Dublin Core:Description'] = $element->id;
     $elements = $elementsTable->findBySet($elementSetName);
     foreach ($elements as $element) {
         $elementIds[$elementSetName . ':' . $element->name] = $element->id;
     }
     $this->_options['videostream_elements_ids'] = json_encode($elementIds);
     $this->_installOptions();
 }
 /**
  * Install the plugin.
  */
 public function hookInstall()
 {
     if ($this->_db->getTable('ElementSet')->findByName(self::ELEMENT_SET_NAME)) {
         throw new Omeka_Plugin_Installer_Exception(__('An element set by the name "%s" already exists. You must delete that element set to install this plugin.', self::ELEMENT_SET_NAME));
     }
     // Insert the Zotero element set.
     $elements = array();
     foreach (self::$zoteroFields as $zoteroFieldName => $fieldMap) {
         if ('creator' == $zoteroFieldName) {
             foreach ($fieldMap as $zoteroCreatorName => $creatorMap) {
                 $creatorName = is_array($creatorMap) ? $creatorMap[0] : $creatorMap;
                 $elements[] = array('name' => $creatorName, 'data_type' => 'Tiny Text');
             }
         } else {
             $fieldName = is_array($fieldMap) ? $fieldMap[0] : $fieldMap;
             $elements[] = array('name' => $fieldName, 'data_type' => 'Tiny Text');
         }
     }
     insert_element_set(self::ELEMENT_SET_NAME, $elements);
     // Create the plugin's tables.
     $sql = "\n        CREATE TABLE IF NOT EXISTS `{$this->_db->prefix}zotero_import_imports` (\n          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n          `process_id` int(10) unsigned DEFAULT NULL,\n          `collection_id` int(10) unsigned DEFAULT NULL,\n          PRIMARY KEY (`id`)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
     $this->_db->query($sql);
     $sql = "\n        CREATE TABLE IF NOT EXISTS `{$this->_db->prefix}zotero_import_items` (\n          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n          `import_id` int(10) unsigned NOT NULL,\n          `item_id` int(10) unsigned DEFAULT NULL,\n          `zotero_item_key` varchar(50) COLLATE utf8_unicode_ci NOT NULL,\n          `zotero_item_parent_key` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n          `zotero_item_type` varchar(30) COLLATE utf8_unicode_ci NOT NULL,\n          `zotero_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n          PRIMARY KEY (`id`)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
     $this->_db->query($sql);
 }
Esempio n. 3
0
 public function testCanInsertElementSet()
 {
     $elementSet = insert_element_set(array('name' => 'Foobar Element Set', 'description' => 'foobar'), array(array('name' => 'Element Name', 'description' => 'Element Description')));
     $this->assertThat($elementSet, $this->isInstanceOf('ElementSet'));
     $this->assertTrue($elementSet->exists());
     $elements = $elementSet->getElements();
     $this->assertEquals(1, count($elements));
 }
Esempio n. 4
0
 /**
  * Install table, options and element set
  */
 public function hookInstall()
 {
     $db = $this->_db;
     $sql = "\n            CREATE TABLE IF NOT EXISTS `{$db->Rating}` (\n              `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n              `record_id` int(10) unsigned NOT NULL,\n              `rating` float(2,1) NOT NULL DEFAULT '0',\n              `user_id` int(11) DEFAULT NULL,\n              PRIMARY KEY (`id`)\n            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n        ";
     $db->query($sql);
     // Install and set basic options
     $this->_installOptions();
     set_option('ratings_rating_roles', serialize(array()));
     insert_element_set($this->_elementSet, $this->_elements);
 }
Esempio n. 5
0
 /**
  * Install Scripto.
  */
 public function hookInstall()
 {
     // Don't install if an element set by the name "Scripto" already exists.
     if ($this->_db->getTable('ElementSet')->findByName(self::ELEMENT_SET_NAME)) {
         throw new Omeka_Plugin_Installer_Exception(__('An element set by the name "%s" already exists. You must delete ' . 'that element set to install this plugin.', self::ELEMENT_SET_NAME));
     }
     $elementSetMetadata = array('name' => self::ELEMENT_SET_NAME);
     $elements = array(array('name' => 'Transcription', 'description' => 'A written representation of a document.'));
     insert_element_set($elementSetMetadata, $elements);
 }
Esempio n. 6
0
 /**
  * Install the plugin.
  */
 public function hookInstall()
 {
     // Don't install if the pdftotext command doesn't exist.
     // See: http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
     if ((int) shell_exec('hash pdftotext 2>&- || echo 1')) {
         throw new Omeka_Plugin_Installer_Exception(__('The pdftotext command-line utility ' . 'is not installed. pdftotext must be installed to install this plugin.'));
     }
     // Don't install if a PDF element set already exists.
     if ($this->_db->getTable('ElementSet')->findByName(self::ELEMENT_SET_NAME)) {
         throw new Omeka_Plugin_Installer_Exception(__('An element set by the name "%s" already ' . 'exists. You must delete that element set to install this plugin.', self::ELEMENT_SET_NAME));
     }
     insert_element_set(array('name' => self::ELEMENT_SET_NAME, 'record_type' => 'File'), array(array('name' => self::ELEMENT_NAME)));
 }
Esempio n. 7
0
 public function hookInstall()
 {
     set_option('jwplayer_width_public', VideoStreamPlugin::DEFAULT_VIEWER_WIDTH);
     set_option('jwplayer_height_public', VideoStreamPlugin::DEFAULT_VIEWER_HEIGHT);
     set_option('jwplayer_external_control', VideoStreamPlugin::DEFAULT_VIEWER_CONTROL);
     set_option('jwplayer_display_current', VideoStreamPlugin::DEFAULT_VIEWER_DISPLAY);
     set_option('jwplayer_external_skin', VideoStreamPlugin::DEFAULT_VIEWER_SKIN);
     set_option('jwplayer_flash_streaming', VideoStreamPlugin::DEFAULT_VIEWER_FLASH);
     set_option('jwplayer_http_streaming', VideoStreamPlugin::DEFAULT_VIEWER_HTTP);
     set_option('jwplayer_hls_streaming', VideoStreamPlugin::DEFAULT_VIEWER_HLS);
     set_option('jwplayer_flash_primary', VideoStreamPlugin::DEFAULT_VIEWER_PRIMARY);
     set_option('jwplayer_autostart', VideoStreamPlugin::DEFAULT_VIEWER_AUTOSTART);
     set_option('jwplayer_tuning', VideoStreamPlugin::DEFAULT_VIEWER_TUNING);
     $db = get_db();
     // Don't install if an element set named "Streaming Video" already exists.
     if ($db->getTable('ElementSet')->findByName('Streaming Video')) {
         throw new Exception('An element set by the name "Streaming Video" already exists. You must delete that ' . 'element set to install this plugin.');
     }
     $elementSetMetadata = array('record_type' => "Item", 'name' => "Streaming Video", 'description' => "Elements needed for streaming video for the VideoStream Plugin");
     $elements = array(array('name' => "Video Filename", 'description' => "Actual filename of the video on the video source server"), array('name' => "Video Streaming URL", 'description' => "Actual URL of the streaming server without the filename"), array('name' => "Video Type", 'description' => "Encoding for the video; mp4, flv, mov, and so forth"), array('name' => "HLS Streaming Directory", 'description' => "Directory location on your server for the HLS .m3u8 file."), array('name' => "HLS Video Filename", 'description' => "Filename for HLS video file. Include any subdirectories."), array('name' => "HTTP Streaming Directory", 'description' => "Directory location for files to HTTP stream directly from Web Server."), array('name' => "HTTP Video Filename", 'description' => "Actual filename of the video on the web server"), array('name' => "Segment Start", 'description' => "Start point in video in either seconds or hh:mm:ss"), array('name' => "Segment End", 'description' => "End point in video in either seconds or hh:mm:ss"), array('name' => "Segment Type", 'description' => "Use segment type to help determine how segment is to be displayed. For instance, an event may encompass many scenes, etc."), array('name' => "Show Item", 'description' => "Should item be shown in a list. Can be useful in cetain types of displays where you may not want to have all items shown."), array('name' => "Video Source", 'description' => "Source of video. Streaming server, YouTube, etc."));
     insert_element_set($elementSetMetadata, $elements);
 }
Esempio n. 8
0
 protected function installElementSets()
 {
     $elSetData = array('name' => 'Newspaper Metadata', 'description' => 'Data about newspapers from Chronicling America');
     $elementsData = array(array('name' => 'place_of_publication'), array('name' => 'lccn'), array('name' => 'start_year'), array('name' => 'end_year'), array('name' => 'url'), array('name' => 'place'), array('name' => 'columns'), array('name' => 'state'));
     insert_element_set($elSetData, $elementsData);
 }
Esempio n. 9
0
 public function testInsertItemTypeAndInsertElementSetHaveSimilarArguments()
 {
     // Insert an item type.
     $itemType = insert_item_type(array('name' => 'Foobar', 'description' => 'Changed description.'), array(array('name' => 'Wonder'), array('name' => 'Years')));
     $elementSet = insert_element_set(array('name' => 'Foobar Element Set', 'description' => 'foobar'), array(array('name' => 'Element Name', 'description' => 'Element Description')));
 }
 private function _setScriptoSet()
 {
     // Create the set if needed.
     $elementSet = get_record('ElementSet', array('name' => self::ELEMENT_SET_NAME));
     if (!$elementSet) {
         $elementSetMetadata = array('name' => self::ELEMENT_SET_NAME, 'description' => 'Manages transcriptions of items and files', 'record_type' => NULL);
         insert_element_set($elementSetMetadata, array());
         $elementSet = get_record('ElementSet', array('name' => self::ELEMENT_SET_NAME));
     }
     // Fill the set if needed.
     $elements = array(array('name' => 'Transcription', 'description' => 'A written representation of a document or a page.'), array('name' => 'Status', 'description' => 'The current transcription status of a document or a page.'), array('name' => 'Percent Needs Review', 'description' => 'The percentage of pages with Needs Review status.'), array('name' => 'Percent Completed', 'description' => 'The percentage of pages with Completed status.'), array('name' => 'Weight', 'description' => 'A 6-digit number used to sort items quickly.'));
     // Remove existing elements.
     $existingElements = $elementSet->getElements();
     foreach ($existingElements as $existingElement) {
         foreach ($elements as $key => $newElement) {
             if ($newElement['name'] == $existingElement->name) {
                 unset($elements[$key]);
             }
         }
     }
     // Save new elements if any.
     $elementSet->addElements($elements);
     $elementSet->save();
 }