本文整理汇总了PHP中get_record_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_record_by_id函数的具体用法?PHP get_record_by_id怎么用?PHP get_record_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_record_by_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCollectionName
public function getCollectionName()
{
if (is_numeric($this->collection_id) && $this->collection_id > 0) {
$collection = get_record_by_id('Collection', $this->collection_id);
return $collection->name;
}
}
示例2: afterSave
/**
* Update item after saving the tagging.
*/
protected function afterSave($args)
{
switch ($this->status) {
case 'proposed':
break;
case 'allowed':
case 'approved':
$item = get_record_by_id($this->record_type, $this->record_id);
$item->addTags($this->name);
try {
$item->save();
} catch (Exception $e) {
_log($e->getMessage());
}
break;
case 'rejected':
$item = get_record_by_id($this->record_type, $this->record_id);
$item->deleteTags($this->name);
try {
$item->save();
} catch (Exception $e) {
_log($e->getMessage());
}
break;
}
}
示例3: emiglio_exhibit_builder_page_nav
function emiglio_exhibit_builder_page_nav($exhibitPage = null, $currentPageId)
{
if (!$exhibitPage) {
$exhibitPage = get_current_record('exhibit_page');
}
$parents = array();
$currentPage = get_record_by_id('Exhibit Page', $currentPageId);
while ($currentPage->parent_id) {
$currentPage = $currentPage->getParent();
array_unshift($parents, $currentPage->id);
}
$class = '';
$class .= $exhibitPage->id == $currentPageId ? 'current' : '';
$parent = array_search($exhibitPage->id, $parents) !== false ? ' parent' : '';
$html = '<li class="' . $class . $parent . '">' . '<a href="' . exhibit_builder_exhibit_uri(get_current_record('exhibit'), $exhibitPage) . '">' . metadata($exhibitPage, 'title') . '</a>';
$children = $exhibitPage->getChildPages();
if ($children) {
$html .= '<ul>';
foreach ($children as $child) {
$html .= emiglio_exhibit_builder_page_nav($child, $currentPageId);
release_object($child);
}
$html .= '</ul>';
}
$html .= '</li>';
return $html;
}
示例4: map
/**
* Map a row to an array that can be parsed by insert_item() or
* insert_files_for_item().
*
* @param array $row The row to map
* @param array $result
* @return array|false The result
*/
public function map($row, $result)
{
$collectionIdentifier = trim($row[$this->_columnName]);
// In "Manage" format, collection is determined at row level, according
// to field of the identifier, so only content of the cell is returned.
if ($this->_advanced) {
if (empty($collectionIdentifier) && !empty($this->_collectionId)) {
$collectionIdentifier = $this->_collectionId;
}
return $collectionIdentifier;
}
$result = false;
if ($collectionIdentifier !== '') {
if (is_numeric($collectionIdentifier) && (int) $collectionIdentifier > 0) {
$collection = get_record_by_id('Collection', $collectionIdentifier);
}
if (empty($collection)) {
$collection = $this->_getCollectionByTitle($collectionIdentifier);
}
if (empty($collection) && $this->_createCollection) {
$collection = $this->_createCollectionFromTitle($collectionIdentifier);
}
if ($collection) {
$result = $collection->id;
}
} else {
$result = $this->_collectionId;
}
return $result;
}
示例5: viewAction
public function viewAction()
{
$id = $this->getParam('id');
$item = get_record_by_id('Item', $id);
if (empty($item)) {
throw new Omeka_Controller_Exception_404();
}
$relations = metadata($item, array('Dublin Core', 'Relation'), array('all' => true, 'no_escape' => true, 'no_filter' => true));
// Currently, only support gDoc urls.
$tableUrl = '';
$baseUrl = 'https://spreadsheets.google.com/feeds/list/';
$endUrl = '/public/values';
foreach ($relations as $relation) {
if (strpos($relation, $baseUrl) === 0 && substr_compare($relation, $endUrl, -strlen($endUrl), strlen($endUrl)) === 0) {
$tableUrl = $relation;
break;
}
}
if (empty($tableUrl)) {
$this->_helper->flashMessenger(__('This item has no table of images.'), 'error');
return $this->forward('show', 'items', 'default', array('module' => null, 'controller' => 'items', 'action' => 'show', 'id' => $item->id));
}
$this->_prepareViewer($item);
$this->view->tableUrl = $tableUrl . '?alt=json-in-script&callback=spreadsheetLoaded';
}
示例6: recordAction
public function recordAction()
{
$item = get_record_by_id("Item", $this->getParam('id'));
$this->view->item = $item;
$this->view->title = is_object($item) ? metadata($this->view->item, array('Dublin Core', 'Title')) : "Untitled";
$this->view->username = is_object($user = current_user()) ? $user->name : "";
$this->view->email = is_object($user) ? $user->email : "";
}
示例7: setItem
/**
* Set item.
*
* @param integer|Item $item
*/
public function setItem($item)
{
if (empty($item)) {
$this->_item = null;
} elseif ($item instanceof Item) {
$this->_item = $item;
} else {
$this->_item = get_record_by_id('Item', (int) $item);
}
}
示例8: prepareObjectRelations
/**
* Prepare object item relations for display.
*
* @param Item $item
* @return array
*/
public static function prepareObjectRelations(Item $item)
{
$objects = get_db()->getTable('ItemRelationsRelation')->findByObjectItemId($item->id);
$objectRelations = array();
foreach ($objects as $object) {
if (!($item = get_record_by_id('item', $object->subject_item_id))) {
continue;
}
$objectRelations[] = array('item_relation_id' => $object->id, 'subject_item_id' => $object->subject_item_id, 'subject_item_title' => self::getItemTitle($item), 'relation_text' => $object->getPropertyText(), 'relation_description' => $object->property_description);
}
return $objectRelations;
}
示例9: get_child_collections
function get_child_collections($collectionId)
{
if (plugin_is_active('CollectionTree')) {
$treeChildren = get_db()->getTable('CollectionTree')->getChildCollections($collectionId);
$childCollections = array();
foreach ($treeChildren as $treeChild) {
$childCollections[] = get_record_by_id('collection', $treeChild['id']);
}
return $childCollections;
}
return array();
}
示例10: playAction
public function playAction()
{
$id = $this->getParam('id');
if (empty($id)) {
throw new Omeka_Controller_Exception_404();
}
$recordType = $this->getParam('recordtype');
$record = get_record_by_id(Inflector::classify($recordType), $id);
if (empty($record)) {
throw new Omeka_Controller_Exception_404();
}
$this->view->record = $record;
}
示例11: getRecordByTitle
/**
* Get a record by title.
*
* @internal This function allows a quick check of records, because id can
* change between tests.
*/
protected function getRecordByTitle($title)
{
$record = null;
$elementSetName = 'Dublin Core';
$elementName = 'Title';
$element = $this->db->getTable('Element')->findByElementSetNameAndElementName($elementSetName, $elementName);
$elementTexts = $this->db->getTable('ElementText')->findBy(array('element_id' => $element->id, 'text' => $title), 1);
$elementText = reset($elementTexts);
if ($elementText) {
$record = get_record_by_id($elementText->record_type, $elementText->record_id);
}
return $record;
}
示例12: checkItemElement
public function checkItemElement()
{
$elements = false;
$title = "";
$elementTitle = "";
$output = "";
$returnLink = "<a href='javascript:window.history.back();'>" . __("Please return to the referring page.") . "</a>";
$itemId = isset($_GET["item"]) ? intval($_GET["item"]) : 0;
$elementId = isset($_GET["element"]) ? intval($_GET["element"]) : 0;
if (!$itemId) {
$output .= __("No item ID specified.") . " " . $returnLink;
} else {
if (!$elementId) {
$output .= __("No element ID specified.") . " " . $returnLink;
} else {
$db = get_db();
$itemExists = $db->fetchOne("SELECT count(*) FROM {$db->Items} WHERE id = {$itemId}");
$elementTitle = $db->fetchOne("SELECT name FROM {$db->Elements} WHERE id = {$elementId}");
if (!$itemExists) {
$output .= __("Item not found.") . " " . $returnLink;
} else {
if (!$elementTitle) {
$output .= __("Element not found.") . " " . $returnLink;
} else {
$sql = "SELECT * FROM {$db->ElementTexts}" . " WHERE record_id = {$itemId}" . " AND element_id = {$elementId}";
$elements = $db->fetchAll($sql);
if (!$elements) {
$output .= __("Specified elements not found in item.") . " " . $returnLink;
} else {
$title = __("Item") . " #" . $itemId;
$item = get_record_by_id('Item', $itemId);
$titleVerb = metadata($item, array('Dublin Core', 'Title'));
if ($titleVerb) {
$title .= ': "' . $titleVerb . '"';
}
$sql = "\n SELECT es.name\n FROM {$db->ElementSets} es\n JOIN {$db->Elements} el\n ON es.id = el.element_set_id\n WHERE el.id = {$elementId}\n ";
$elementSet = $db->fetchOne($sql);
$elementsFiltered = metadata($item, array($elementSet, $elementTitle), array('all' => true, 'no_filter' => false));
foreach (array_keys($elements) as $idx) {
$elements[$idx]["filtered"] = $elementsFiltered[$idx];
}
// echo "<pre>" . print_r($elements,true) . "</pre>"; die();
}
}
}
}
}
$result = array("elements" => $elements, "output" => $output, "title" => $title, "elementTitle" => $elementTitle);
// echo "<pre>" . print_r($result,true) . "</pre>"; die();
return $result;
}
示例13: alternativeManifestAction
public function alternativeManifestAction()
{
$id = $this->getParam('id');
if (empty($id)) {
throw new Omeka_Controller_Exception_404();
}
$recordType = $this->getParam('recordtype');
$record = get_record_by_id(Inflector::classify($recordType), $id);
if (empty($record)) {
throw new Omeka_Controller_Exception_404();
}
$manifest = get_view()->iiifManifest($record, false, true, $this->getParam('image'));
$this->_sendJson($manifest);
}
示例14: getBookReader
/**
* Get the specified BookReader.
*
* @param array $args Associative array of optional values:
* - (integer|Item) item: The item is the current one if not set.
* - (integer) page: set the page to be shown when including the iframe.
* - (boolean) embed_functions: include buttons (Zoom, Search...).
* - (integer) mode_page: allow to display 1 or 2 pages side-by-side.
* - (integer) part: can be used to display the specified part of a book.
*
* @return string. The html string corresponding to the BookReader.
*/
public function getBookReader($args = array())
{
if (!isset($args['item'])) {
$item = get_current_record('item');
} elseif ($args['item'] instanceof Item) {
$item = $args['item'];
} else {
$item = get_record_by_id('Item', (int) $args['item']);
}
if (empty($item)) {
return '';
}
$part = empty($args['part']) ? 0 : (int) $args['part'];
$page = empty($args['page']) ? '0' : $args['page'];
// Currently, all or none functions are enabled.
$embed_functions = isset($args['embed_functions']) ? $args['embed_functions'] : get_option('bookreader_embed_functions');
// TODO Count leaves, not files.
if ($item->fileCount() > 1) {
$mode_page = isset($args['mode_page']) ? $args['mode_page'] : get_option('bookreader_mode_page');
} else {
$mode_page = 1;
}
// Build url of the page with iframe.
$queryParams = array();
if ($part > 1) {
$queryParams['part'] = $part;
}
if (empty($embed_functions)) {
$queryParams['ui'] = 'embed';
}
$url = absolute_url(array('id' => $item->id), 'bookreader_viewer', $queryParams);
$url .= '#';
$url .= empty($page) ? '' : 'page/n' . $page . '/';
$url .= 'mode/' . $mode_page . 'up';
$class = get_option('bookreader_class');
if (!empty($class)) {
$class = ' class="' . $class . '"';
}
$width = get_option('bookreader_width');
if (!empty($width)) {
$width = ' width="' . $width . '"';
}
$height = get_option('bookreader_height');
if (!empty($height)) {
$height = ' height="' . $height . '"';
}
$html = '<div><iframe src="' . $url . '"' . $class . $width . $height . ' frameborder="0"></iframe></div>';
return $html;
}
示例15: perform
/**
* Perform this job.
*/
public function perform()
{
// Fetch file IDs according to the passed options.
$select = $this->_db->select()->from($this->_db->File, array('id'));
if ('has_derivative' == $this->_options['process_type']) {
$select->where('has_derivative_image = 1');
} else {
if ('has_no_derivative' == $this->_options['process_type']) {
$select->where('has_derivative_image = 0');
}
}
if (is_array($this->_options['mime_types'])) {
$select->where('mime_type IN (?)', $this->_options['mime_types']);
}
$fileIds = $select->query()->fetchAll(Zend_Db::FETCH_COLUMN);
// Iterate files and create derivatives.
foreach ($fileIds as $fileId) {
$file = get_record_by_id('file', $fileId);
// Register which image derivatives to create.
foreach ($this->_derivatives as $type => $constraint) {
$this->_imageCreator->addDerivative($type, $constraint);
}
// Create derivatives.
try {
$imageCreated = $this->_imageCreator->create(FILES_DIR . '/' . $file->getStoragePath('original'), $file->getDerivativeFilename(), $file->mime_type);
} catch (Exception $e) {
_log($e);
$imageCreated = false;
}
// Confirm that the file was derivable.
if (!$imageCreated) {
continue;
}
// Save the file record.
$file->has_derivative_image = 1;
$file->save();
// Delete existing derivative images and replace them with the
// temporary ones made during image creation above.
foreach ($this->_derivatives as $type => $constraint) {
$this->_storage->delete($file->getStoragePath($type));
$source = FILES_DIR . "/original/{$type}_" . $file->getDerivativeFilename();
$this->_storage->store($source, $file->getStoragePath($type));
}
// Release the file record to prevent memory leaks.
release_object($file);
}
}