当前位置: 首页>>代码示例>>PHP>>正文


PHP insert_item函数代码示例

本文整理汇总了PHP中insert_item函数的典型用法代码示例。如果您正苦于以下问题:PHP insert_item函数的具体用法?PHP insert_item怎么用?PHP insert_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了insert_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     $pluginHelper = new Omeka_Test_Helper_Plugin();
     $pluginHelper->setUp(self::PLUGIN_NAME);
     define('TEST_FILES_DIR', ARCHIVE_REPERTORY_DIR . '/tests/suite/_files');
     // Add constraints if derivatives have been added in the config file.
     $fileDerivatives = Zend_Registry::get('bootstrap')->getResource('Config')->fileDerivatives;
     if (!empty($fileDerivatives) && !empty($fileDerivatives->paths)) {
         foreach ($fileDerivatives->paths->toArray() as $type => $path) {
             set_option($type . '_constraint', 1);
         }
     }
     // Prepare config and set a test temporary storage in registry.
     $config = new Omeka_Test_Resource_Config();
     $configIni = $config->init();
     if (isset($configIni->paths->imagemagick)) {
         $this->convertDir = $configIni->paths->imagemagick;
     } else {
         $this->convertDir = dirname(`which convert`);
     }
     $storage = Zend_Registry::get('storage');
     $adapter = $storage->getAdapter();
     $adapterOptions = $adapter->getOptions();
     $this->_storagePath = $adapterOptions['localDir'];
     // Set default strategy for the creation of derivative files.
     $this->strategy = new Omeka_File_Derivative_Strategy_ExternalImageMagick();
     $this->strategy->setOptions(array('path_to_convert' => $this->convertDir));
     $this->creator = new Omeka_File_Derivative_Creator();
     $this->creator->setStrategy($this->strategy);
     Zend_Registry::set('file_derivative_creator', $this->creator);
     // Create one item on which attach files.
     $this->item = insert_item(array('public' => true));
     set_option('disable_default_file_validation', 1);
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:35,代码来源:ArchiveRepertory_Test_AppTestCase.php

示例2: importItem

 protected function importItem($collectionObject)
 {
     $itemMetadataArray = array();
     $itemMetadataArray = $this->fetchItemMetadata($collectionObject, $itemMetadataArray);
     $item = insert_item($metadata, $itemMetadataArray, $fileMetadataArray);
     $importRecord = new ImportRecord();
     $itemporRecord->csid = $whatever;
     $importRecord->item_id = $item->id;
     $importRecord->save();
 }
开发者ID:patrickmj,项目名称:CollectionSpaceImport,代码行数:10,代码来源:ImportJob.php

示例3: testSearchIndexedElements

 /**
  * Search queries should match indexed elements.
  */
 public function testSearchIndexedElements()
 {
     $this->fieldTable->setElementIndexed('Dublin Core', 'Description');
     $item1 = insert_item(array('public' => true), array('Dublin Core' => array('Title' => array(array('text' => 'Item 1', 'html' => false)), 'Description' => array(array('text' => 'desc1', 'html' => false)))));
     $item2 = insert_item(array('public' => true), array('Dublin Core' => array('Title' => array(array('text' => 'Item 2', 'html' => false)), 'Description' => array(array('text' => 'desc2', 'html' => false)))));
     $_GET['q'] = 'desc1';
     $this->dispatch('solr-search');
     // Should match item 1, but not item 2.
     $this->_assertResultLink(record_url($item1), 'Item 1');
     $this->_assertNotResultLink(record_url($item2));
 }
开发者ID:rameysar,项目名称:Omeka-Grinnell-RomanCiv,代码行数:14,代码来源:SearchItemsTest.php

示例4: testCanInsertItem

 public function testCanInsertItem()
 {
     $db = $this->db;
     // Insert an item and verify with a second query.
     $item = insert_item(array('public' => true), array('Dublin Core' => array('Title' => array(array('text' => 'foobar', 'html' => true)))));
     $sql = "SELECT public FROM {$db->Item} WHERE id = {$item->id}";
     $row = $db->fetchRow($sql);
     $this->assertEquals(array('public' => 1), $row);
     // Verify that element texts are inserted correctly into the database.
     $sql = "SELECT COUNT(id) FROM {$db->ElementText} WHERE html = 1 AND " . "text = 'foobar' AND record_id = {$item->id}";
     $this->assertEquals(1, $db->fetchOne($sql));
     release_object($item);
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:13,代码来源:InsertItemTest.php

示例5: doImport

 public function doImport()
 {
     _log("Feed Import Started at " . date('c'));
     $db = get_db();
     $hasError = false;
     require_once PLUGIN_DIR . "/FeedImporter/libraries/SimplePie/simplepie.inc";
     $this->fi_feed = $db->getTable('FeedImporter_Feed')->find($this->feed_id);
     $this->fi_tags = $db->getTable('FeedImporter_TagConfig')->findByFeedId($this->feed_id, true);
     if ($this->fi_feed->map_authors) {
         $this->authorsMap = unserialize($this->fi_feed->authors_map);
     }
     $sp_feed = new SimplePie();
     $sp_feed->enable_cache(false);
     $sp_feed->set_feed_url($this->fi_feed->feed_url);
     $sp_feed->handle_content_type();
     // Run SimplePie.
     $sp_feed->init();
     if ($sp_feed->error()) {
         $hasError = true;
         $this->status = self::STATUS_FEED_ERRORS;
         $this->sp_error = $sp_feed->error();
         $this->save();
         return false;
     }
     if (!$hasError) {
         foreach ($sp_feed->get_items() as $sp_item) {
             if ($this->_needsImport($sp_item)) {
                 $this->processItemTags($sp_item);
                 $metadataArray = $this->buildFeedItemMetadata($sp_item);
                 $elementTextsArray = $this->buildFeedItemElementTexts($sp_item);
                 $newOmekaItem = insert_item($metadataArray, $elementTextsArray);
                 $newImportedItem = new FeedImporter_ImportedItem();
                 $newImportedItem->item_id = $newOmekaItem->id;
                 $newImportedItem->feed_id = $this->fi_feed->id;
                 $newImportedItem->import_id = $this->id;
                 $newImportedItem->sp_id = $sp_item->get_id();
                 $newImportedItem->save();
                 $this->_buildFeedItemItemTypeData($sp_item, $newOmekaItem);
                 $license = $sp_item->get_link(0, 'license');
                 if ($this->fi_feed->import_media && !empty($license)) {
                     $this->_doFileImportForItem($sp_item, $newOmekaItem);
                 }
             }
         }
     }
     $this->status = self::STATUS_COMPLETED_IMPORT;
     $this->save();
     return true;
 }
开发者ID:patrickmj,项目名称:FeedImporter,代码行数:49,代码来源:Import.php

示例6: testNoDisplayPrivate

 /**
  * When a new private item is added, it should not be indexed in Solr.
  */
 public function testNoDisplayPrivate()
 {
     $opt = get_option('solr_search_display_private_items');
     set_option('solr_search_display_private_items', '0');
     try {
         $item = insert_item(array('public' => false), array('Dublin Core' => array('Title' => array(array('text' => 'testNoDisplayPrivate', 'html' => false)))));
         $this->_assertRecordInSolr($item);
         $_GET['q'] = 'testNoDisplayPrivate';
         $this->dispatch('solr-search');
         $this->assertNotQueryContentContains('.result-title', 'testNoDisplayPrivate');
     } catch (Exception $e) {
         throw $e;
     } finally {
         set_option('solr_search_display_private_items', $opt);
     }
 }
开发者ID:fitnycdigitalinitiatives,项目名称:SolrSearch,代码行数:19,代码来源:DisplayResultsTest.php

示例7: testItemsShowPanel

 public function testItemsShowPanel()
 {
     $this->_authenticateUser($this->_getDefaultUser());
     $orig = insert_item();
     $dup1 = insert_item();
     $dup2 = insert_item();
     $identifier = 'my-fake-id';
     $datestamp = '2011-07-24';
     $harvestId = 10000;
     foreach (array($orig, $dup1, $dup2) as $item) {
         $record = new OaipmhHarvester_Record();
         $record->setArray(array('identifier' => $identifier, 'item_id' => $item->id, 'datestamp' => $datestamp, 'harvest_id' => $harvestId));
         $record->save();
     }
     $this->dispatch('/items/show/' . $orig->id);
     $this->assertQuery('div#harvester-duplicates');
     $this->assertQueryCount('div#harvester-duplicates li', 2, "Should be 2 duplicates of this item.");
 }
开发者ID:kyfr59,项目名称:cg35,代码行数:18,代码来源:HooksTest.php

示例8: import

 public function import()
 {
     //grab the data needed for using update_item or insert_item
     $elementTexts = $this->elementTexts();
     $itemMetadata = $this->itemMetadata();
     //avoid accidental duplications
     if ($this->record && $this->record->exists()) {
         $itemMetadata['overwriteElementTexts'] = true;
         update_item($this->record, $itemMetadata, $elementTexts);
         $this->updateItemOwner($this->record);
     } else {
         $this->record = insert_item($itemMetadata, $elementTexts);
         //dig up the correct owner information, importing the user if needed
         $this->updateItemOwner($this->record);
         $this->addOmekaApiImportRecordIdMap();
     }
     //import files after the item is there, so the file has an item id to use
     //we're also keeping track of the correspondences between local and remote
     //file ids, so we have to introduce this little inefficiency of not passing
     //the file data
     $this->importFiles($this->record);
 }
开发者ID:Daniel-KM,项目名称:OmekaApiImport,代码行数:22,代码来源:ItemAdapter.php

示例9: testRecordExists

 public function testRecordExists()
 {
     $record = new OaipmhHarvester_Record();
     $item = insert_item(array('public' => true));
     $harvest = new OaipmhHarvester_Harvest();
     $record->item_id = $item->id;
     $record->identifier = 'foo-bar';
     $record->datestamp = '2010-04-28';
     $harvest->base_url = 'http://example.com';
     $harvest->metadata_prefix = 'oai_dc';
     $harvest->status = OaipmhHarvester_Harvest::STATUS_COMPLETED;
     $request = new OaipmhHarvester_Request_Mock();
     $xmlFile = dirname(__FILE__) . '/_files/ListRecords.xml';
     $request->setResponseXml(file_get_contents($xmlFile));
     $harvest->setRequest($request);
     $harvest->save();
     $record->harvest_id = $harvest->id;
     $record->save();
     $harvester = new OaipmhHarvester_Harvest_OaiDc($harvest);
     $harvester->harvest();
     $item = $this->db->getTable('Item')->find($record->item_id);
     $this->assertEquals("Record Title", metadata($item, array('Dublin Core', 'Title')));
 }
开发者ID:kyfr59,项目名称:cg35,代码行数:23,代码来源:AbstractTest.php

示例10: _uploadFiles

 /**
  * Create a new Item for each of the given files.
  *
  * @param array $filenames
  * @return array An array of errors that occurred when creating the
  *  Items, indexed by the filename that caused the error.
  */
 protected function _uploadFiles($fileNames)
 {
     if (!dropbox_can_access_files_dir()) {
         throw new Dropbox_Exception('The Dropbox files directory must be both readable and writable.');
     }
     $fileErrors = array();
     foreach ($fileNames as $fileName) {
         $item = null;
         try {
             $filePath = dropbox_validate_file($fileName);
             $itemMetadata = array('public' => $_POST['dropbox-public'], 'featured' => $_POST['dropbox-featured'], 'collection_id' => $_POST['dropbox-collection-id'] ? $_POST['dropbox-collection-id'] : null, 'tags' => $_POST['dropbox-tags']);
             $elementTexts = array('Dublin Core' => array('Title' => array(array('text' => $fileName, 'html' => false))));
             $fileMetadata = array('file_transfer_type' => 'Filesystem', 'file_ingest_options' => array('ignore_invalid_files' => false), 'files' => array($filePath));
             $item = insert_item($itemMetadata, $elementTexts, $fileMetadata);
             release_object($item);
             // delete the file from the dropbox folder
             unlink($filePath);
         } catch (Exception $e) {
             release_object($item);
             $fileErrors[$fileName] = $e->getMessage();
         }
     }
     return $fileErrors;
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:31,代码来源:IndexController.php

示例11: _prepareRecords

 /**
  * Set some records with identifier to test.
  */
 protected function _prepareRecords()
 {
     // Remove default records.
     $this->_deleteAllRecords();
     $metadata = array('public' => true);
     $isHtml = false;
     $collections = array();
     $items = array();
     $files = array();
     foreach ($this->_recordsByType as $type => $recordsMetadata) {
         foreach ($recordsMetadata as $recordMetadata) {
             $identifiers = array();
             foreach ($recordMetadata['Identifier'] as $identifier) {
                 $identifiers[] = array('text' => $identifier, 'html' => $isHtml);
             }
             $elementTexts = array('Dublin Core' => array('Title' => array(array('text' => $recordMetadata['Title'], 'html' => $isHtml)), 'Identifier' => $identifiers));
             switch ($type) {
                 case 'Collection':
                     $collections[$recordMetadata['collection_id']] = insert_collection($metadata, $elementTexts);
                     break;
                 case 'Item':
                     $metadataItem = $metadata;
                     if (!empty($recordMetadata['collection_id'])) {
                         $metadataItem['collection_id'] = $collections[$recordMetadata['collection_id']]->id;
                     }
                     $record = insert_item($metadataItem, $elementTexts);
                     if (!empty($recordMetadata['files'])) {
                         $fileUrl = TEST_DIR . '/_files/test.txt';
                         $files[$recordMetadata['item_id']] = insert_files_for_item($record, 'Filesystem', array_fill(0, $recordMetadata['files'], $fileUrl));
                     }
                     break;
                 case 'File':
                     $record = $files[$recordMetadata['item_id']][$recordMetadata['file_key']];
                     $record->addElementTextsByArray($elementTexts);
                     $record->save();
                     break;
             }
         }
     }
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:43,代码来源:CleanUrl_Test_AppTestCase.php

示例12: htmlspecialchars

<?php

require_once 'db.php';
if ($_POST) {
    // eсли пeрeдaн мaссив POST
    $entity_type = $_POST["content_type"];
    if ($entity_type == "item") {
        $title = htmlspecialchars($_POST["title"]);
        // пишeм дaнныe в пeрeмeнныe и экрaнируeм спeцсимвoлы
        $description = htmlspecialchars($_POST["description"]);
        $photo = htmlspecialchars($_FILES['file']['name']);
        $json = array();
        // пoдгoтoвим мaссив oтвeтa
        if (!$title or !$description or !$photo) {
            // eсли хoть oднo пoлe oкaзaлoсь пустым
            $json['error'] = 'Вы зaпoлнили нe всe пoля! oбмaнуть рeшили? =)';
            // пишeм oшибку в мaссив
            echo json_encode($json);
            // вывoдим мaссив oтвeтa
            die;
            // умирaeм
        }
        $sourcePath = $_FILES['file']['tmp_name'];
        // Storing source path of the file in a variable
        $targetPath = "gallery/" . $_FILES['file']['name'];
        // Target path where file is to be stored
        move_uploaded_file($sourcePath, $targetPath);
        insert_item($title, $description, $photo);
    }
}
开发者ID:SerebryanskiySergei,项目名称:artduet,代码行数:30,代码来源:request.php

示例13: _addOneItem

 protected function _addOneItem()
 {
     $item = insert_item();
     $this->assertTrue($item->exists());
     return $item;
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:6,代码来源:ItemsControllerTest.php

示例14: handle_item_insert

function handle_item_insert(&$item_r, $HTTP_VARS, &$errors)
{
    if (is_user_granted_permission(PERM_ITEM_OWNER) && $item_r['owner_id'] == get_opendb_session_var('user_id') || is_user_granted_permission(PERM_ITEM_ADMIN)) {
        // Before trying to insert items into this structure, first ensure it is valid.
        if (is_valid_item_type_structure($item_r['s_item_type'])) {
            // We need to get the title
            if (validate_item_attributes('insert', $item_r['s_item_type'], $HTTP_VARS, $errors)) {
                $fieldname = 'title';
                if (!is_array($HTTP_VARS[$fieldname])) {
                    if (preg_match("/new([0-9]+)/", $HTTP_VARS[$fieldname], $matches) && isset($HTTP_VARS[$fieldname . '_' . $matches[0]])) {
                        $fieldname = $fieldname . '_' . $matches[0];
                    }
                }
                $item_r['title'] = $HTTP_VARS[$fieldname];
                $is_exists_owner_title = FALSE;
                $is_exists_title = FALSE;
                // Check owner context
                if (get_opendb_config_var('item_input', 'duplicate_title_support') !== TRUE || $HTTP_VARS['confirmed'] != 'true' && get_opendb_config_var('item_input', 'confirm_duplicate_owner_insert') !== FALSE) {
                    $is_exists_owner_title = is_exists_title($item_r['title'], $item_r['s_item_type'], $item_r['owner_id']);
                }
                // Only check title/s_item_type context
                if (get_opendb_config_var('item_input', 'duplicate_title_support') !== TRUE || $HTTP_VARS['confirmed'] != 'true' && get_opendb_config_var('item_input', 'confirm_duplicate_insert') !== FALSE) {
                    $is_exists_title = is_exists_title($item_r['title'], $item_r['s_item_type']);
                }
                // Unless duplicate title support is allowed we cannot continue.
                if (!$is_exists_title && !$is_exists_owner_title || get_opendb_config_var('item_input', 'duplicate_title_support') !== FALSE) {
                    if (!$is_exists_title && !$is_exists_owner_title) {
                        if ($HTTP_VARS['trial_run'] != 'true') {
                            $new_item_id = insert_item($item_r['s_item_type'], $item_r['title']);
                            if ($new_item_id !== FALSE) {
                                $item_r['item_id'] = $new_item_id;
                                // insert any item level attributes
                                handle_item_attributes('insert', $item_r, $HTTP_VARS, $errors);
                                return TRUE;
                            } else {
                                $db_error = db_error();
                                $errors = array('error' => get_opendb_lang_var('item_not_added'), 'detail' => $db_error);
                                return FALSE;
                            }
                        } else {
                            //if($HTTP_VARS['trial_run'] != 'true')
                            return TRUE;
                        }
                    } else {
                        if ($HTTP_VARS['confirmed'] != 'false') {
                            // if explicitly false, then we are aborting insert.
                            if ($is_exists_owner_title) {
                                $errors = array('error' => get_opendb_lang_var('title_same_type_and_owner_exists', array('title' => $item_r['title'], 's_item_type' => $item_r['s_item_type'])), 'detail' => '');
                                return "__CONFIRM_EXISTS_OWNER_TITLE__";
                            } else {
                                if ($is_exists_title) {
                                    $errors = array('error' => get_opendb_lang_var('title_same_type_exists', array('title' => $item_r['title'], 's_item_type' => $item_r['s_item_type'])), 'detail' => '');
                                    return "__CONFIRM_EXISTS_TITLE__";
                                }
                            }
                        } else {
                            //insert aborted.
                            return "__ABORTED__";
                        }
                    }
                } else {
                    // cannot insert duplicate.
                    if ($is_exists_owner_title) {
                        $errors = array('error' => get_opendb_lang_var('title_same_type_and_owner_exists', array('title' => $item_r['title'], 's_item_type' => $item_r['s_item_type'])), 'detail' => '');
                    } else {
                        if ($is_exists_title) {
                            $errors = array('error' => get_opendb_lang_var('title_same_type_exists', array('title' => $item_r['title'], 's_item_type' => $item_r['s_item_type'])), 'detail' => '');
                        }
                    }
                    return FALSE;
                }
            } else {
                //if(validate_item_attributes("insert", $item_r['s_item_type'], $errors))
                return "__INVALID_DATA__";
            }
        } else {
            // if(is_valid_item_type_structure($item_r['s_item_type']))
            $errors = array('error' => get_opendb_lang_var('invalid_item_type_structure', 's_item_type', $item_r['s_item_type']), 'detail' => '');
            // An error like this is a big problem, and should be dealt with quickly, but there is no sense in alarming the
            // user by sending back an error.
            return FALSE;
        }
    } else {
        // non-admin user attempting to insert item for someone else.
        $errors = array('error' => get_opendb_lang_var('operation_not_available'));
        opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'User attemped to insert an item for another user', $item_r);
        return FALSE;
    }
}
开发者ID:robboor,项目名称:opendb,代码行数:89,代码来源:item_input.php

示例15: _insertItem

 /**
  * Insert a new item into the Omeka database.
  *
  * Post data can be added, unlike insert_item().
  *
  * @see insert_item()
  *
  * @param array $metadata
  * @param array $elementTexts
  * @param array $fileMetadata
  * @param array $postData
  * @return Item
  */
 private function _insertItem($metadata = array(), $elementTexts = array(), $fileMetadata = array(), $postData = array())
 {
     $record = insert_item($metadata, $elementTexts, $fileMetadata);
     $result = $this->_setExtraData($record, $postData, CsvImport_ColumnMap_Action::ACTION_ADD);
     return $record;
 }
开发者ID:HCDigitalScholarship,项目名称:CsvImport,代码行数:19,代码来源:Import.php


注:本文中的insert_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。