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


PHP Resource::update方法代码示例

本文整理汇总了PHP中Resource::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::update方法的具体用法?PHP Resource::update怎么用?PHP Resource::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Resource的用法示例。


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

示例1: saveRecord

 /**
  * Save the record specified by GET parameters.
  *
  * @param object $user User who is saving the record.
  *
  * @return bool        True on success, false on failure.
  * @access public
  */
 public static function saveRecord($user)
 {
     // Fail if the user is not logged in:
     if (!$user) {
         return false;
     }
     $list = new User_list();
     if (isset($_GET['list']) && $_GET['list'] != '') {
         $list->id = $_GET['list'];
     } else {
         if (isset($_POST['list']) && $_POST['list'] != '') {
             $list->id = $_POST['list'];
         } else {
             $list->user_id = $user->id;
             $list->title = "My Favorites";
             if (!$list->find(true)) {
                 $list->insert();
             }
         }
     }
     // Remember that the list was used so it can be the default in future
     // dialog boxes:
     $list->rememberLastUsed();
     // Setup Search Engine Connection
     $db = ConnectionManager::connectToIndex('MetaLib');
     // Get Record Information
     $record = $db->getRecord($_GET['id']);
     if (!$record) {
         return false;
     }
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = 'MetaLib';
     if (!$resource->find(true)) {
         $resource->data = serialize($record);
         $resource->insert();
     } else {
         $resource->data = serialize($record);
         $resource->update();
     }
     preg_match_all('/"[^"]*"|[^ ]+/', isset($_GET['mytags']) ? $_GET['mytags'] : '', $tagArray);
     return $user->addResource($resource, $list, $tagArray[0], isset($_GET['notes']) ? $_GET['notes'] : '');
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:51,代码来源:Save.php

示例2: export

 /**
  * Export record to RefWorks or EndNote.
  *
  * @param array   $record Record
  * @param string  $format Export format (refworks or endnote).
  * @param boolean $render Return rendered template output or the template name?
  *
  * @return void|string
  * @access public
  */
 public function export($record, $format, $render = false)
 {
     global $configArray;
     global $interface;
     if ($record['author']) {
         $record['author2'] = array_slice($record['author'], 1);
     }
     $formats = null;
     $tpl = null;
     if ($format == 'refworks') {
         // Save record to the database, so that also
         // restricted records can be retrieved by RefWorks.
         $resource = new Resource();
         $resource->record_id = $record['id'];
         $resource->source = 'PCI';
         if (!$resource->find(true)) {
             $resource->data = serialize($record);
             $resource->insert();
         } else {
             $resource->data = serialize($record);
             $resource->update();
         }
         $exportUrl = $configArray['Site']['url'] . '/PCI/Record?id=' . urlencode($record['id']) . '&export=refworks_data';
         $url = $configArray['RefWorks']['url'] . '/express/expressimport.asp';
         $url .= '?vendor=' . urlencode($configArray['RefWorks']['vendor']);
         $url .= '&filter=RefWorks%20Tagged%20Format&url=' . urlencode($exportUrl);
         header("Location: {$url}");
         die;
     } else {
         if ($format == 'refworks_data') {
             header('Content-type: text/plain; charset=utf-8');
             if ($record['format']) {
                 $formats = array('article' => 'Journal Article', 'audio' => 'Sound Recording', 'video' => 'Video/ DVD', 'book' => 'Book, Whole', 'book_chapter' => 'Book Section', 'journal' => 'Journal, Electronic');
             }
             $record['format'] = array_key_exists($record['format'], $formats) ? $formats[$record['format']] : 'General';
             $tpl = 'PCI/export-refworks.tpl';
         } else {
             if ($format == 'endnote') {
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Cache-Control: private", false);
                 header('Content-type: application/x-endnote-refer');
                 header("Content-Disposition: attachment; filename=\"vufind.enw\";");
                 if ($record['format']) {
                     $formats = array('article' => 'Journal Article', 'audio' => 'Audiovisual Material', 'audio_video' => 'Audiovisual Material', 'video' => 'Audiovisual Material', 'book' => 'Book', 'book_chapter' => 'Book Section', 'conference_proceeding' => 'Conference Proceedings', 'database' => 'Online Database', 'journal' => 'Journal');
                 }
                 $record['format'] = array_key_exists($record['format'], $formats) ? $formats[$record['format']] : 'Generic';
                 $tpl = 'PCI/export-endnote.tpl';
             }
         }
     }
     if ($tpl) {
         $interface->assign('record', $record);
         if ($render) {
             echo $interface->fetch($tpl);
             exit;
         } else {
             return $tpl;
         }
     }
     return false;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:73,代码来源:PCI.php

示例3: testUpdateShouldUpdateDB

 /**
  * Test update should update data in DB
  *
  * @test
  */
 public function testUpdateShouldUpdateDB()
 {
     $this->migrate('testbench_mysql');
     $stubValue = 'tata';
     \Resource::update(1, ['stubValue' => $stubValue]);
     $response = \Resource::show(1);
     $this->assertTrue($response['stubValue'] == $stubValue);
 }
开发者ID:microffice,项目名称:core,代码行数:13,代码来源:CoreEloquentModelResourceTraitTest.php

示例4: assign

 /**
  * Assign all necessary values to the interface.
  *
  * @return void
  * @access public
  */
 public function assign()
 {
     global $interface;
     $currentSort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'saved';
     if (!isset($this->sortOptions[$currentSort])) {
         $currentSort = 'saved';
     }
     $interface->assign('listEditAllowed', $this->_allowEdit);
     // Get html for the records
     $resourceList = array();
     $searchObjects = array();
     $searchObject = SearchObjectFactory::initSearchObject();
     foreach ($this->_favorites as $favorite) {
         $source = $favorite->source;
         $data = $favorite->data;
         if (!empty($data)) {
             $data = unserialize($data);
         }
         $sortKey = $favorite->saved;
         if ($this->_publicList) {
             $interface->assign('listNotes', $favorite->notes);
         }
         if ($source == 'VuFind') {
             if (empty($data)) {
                 // Fetch data from index for backwards compatibility and store it in the resource
                 $data = $searchObject->getIndexEngine()->getRecord($favorite->record_id);
                 if ($data) {
                     $resource = new Resource();
                     $resource->id = $favorite->id;
                     $resource->source = $favorite->source;
                     if ($resource->find(true)) {
                         $resource->data = serialize($data);
                         $resource->update();
                     }
                 }
             }
             $record = RecordDriverFactory::initRecordDriver($data);
             $tpl = $this->_publicList ? $record->getSearchResult($this->_viewType) : $record->getListEntry($this->_user, $this->_listId, $this->_allowEdit);
             $html = $interface->fetch($tpl);
             switch ($currentSort) {
                 case 'title':
                     $sortKey = isset($data['title_sort']) ? $data['title_sort'] : '';
                     break;
                 case 'author':
                     $sortKey = isset($data['author']) ? $data['author'] : '';
                     break;
                 case 'date':
                     $sortKey = isset($data['main_date_str']) ? $data['main_date_str'] : isset($data['publishDate'][0]) ? $data['publishDate'][0] : '';
                     break;
                 case 'format':
                     $sortKey = isset($data['format'][0]) ? translate($data['format'][0]) : '';
                     break;
             }
         } else {
             if (!isset($searchObjects[$source])) {
                 $searchObjects[$source] = SearchObjectFactory::initSearchObject($source);
                 if ($searchObjects[$source] === false) {
                     error_log("Could not create search object for source '{$source}'");
                     continue;
                 }
             }
             $html = $this->_publicList ? $searchObjects[$source]->getPublicListHTML($data, $this->_viewType) : $searchObjects[$source]->getResultHTML($data, $this->_user, $this->_listId, $this->_allowEdit);
             if ($source == 'MetaLib') {
                 switch ($currentSort) {
                     case 'title':
                         $sortKey = isset($data['Title'][0]) ? $data['Title'][0] : ' ';
                         break;
                     case 'author':
                         $sortKey = isset($data['Author'][0]) ? $data['Author'][0] : ' ';
                         break;
                     case 'date':
                         $sortKey = isset($data['main_date_str']) ? $data['main_date_str'] : isset($data['publicationDate'][0]) ? $data['publicationDate'][0] : ' ';
                         break;
                     case 'format':
                         $sortKey = isset($data['format'][0]) ? translate($data['format'][0]) : ' ';
                         break;
                 }
             } else {
                 switch ($currentSort) {
                     case 'title':
                         $sortKey = isset($data['title']) ? $data['title'] : ' ';
                         break;
                     case 'author':
                         $sortKey = isset($data['author'][0]) ? $data['author'][0] : ' ';
                         break;
                     case 'date':
                         $sortKey = isset($data['main_date_str']) ? $data['main_date_str'] : isset($data['publicationDate']) ? $data['publicationDate'] : ' ';
                         break;
                     case 'format':
                         $sortKey = isset($data['format']) ? translate($data['format']) : ' ';
                         break;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:101,代码来源:FavoriteHandler.php


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