Example #1
0
 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;
     }
 }
Example #2
0
 /**
  * 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;
     }
 }
Example #3
0
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;
}
Example #4
0
 /**
  * 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;
 }
 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';
 }
 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 : "";
 }
Example #7
0
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
Example #9
0
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();
}
 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;
 }
 /**
  * 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;
 }
 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;
 }
Example #13
0
 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);
 }
Example #14
0
 /**
  * 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;
 }
Example #15
0
 /**
  * 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);
     }
 }
Example #16
0
 /**
  * Handle AJAX requests to fill transcription of an item from source
  * element.
  */
 public function fillPagesAction()
 {
     if (!$this->_checkAjax('fill-pages')) {
         return;
     }
     // Handle action.
     try {
         $id = (int) $this->_getParam('id');
         $scripto = ScriptoPlugin::getScripto();
         if (!$scripto->documentExists($id)) {
             $this->getResponse()->setHttpResponseCode(400);
             return;
         }
         // Get some variables.
         list($elementSetName, $elementName) = explode(':', get_option('scripto_source_element'));
         $type = get_option('scripto_import_type');
         $doc = $scripto->getDocument($id);
         // Check all pages, created or not.
         foreach ($doc->getPages() as $pageId => $pageName) {
             // If the page doesn't exist, it is created automatically with
             // text from source element.
             $doc->setPage($pageId);
             // Else, edit the transcription if the page is already created.
             if ($doc->isCreatedPage()) {
                 $file = get_record_by_id('File', $pageId);
                 $transcription = $file->getElementTexts($elementSetName, $elementName);
                 $transcription = empty($transcription) ? '' : $transcription[0]->text;
                 $flagProtect = $doc->isProtectedTranscriptionPage();
                 if ($flagProtect) {
                     $doc->unprotectTranscriptionPage();
                 }
                 $doc->editTranscriptionPage($transcription);
                 // Automatic update of metadata.
                 $doc->setPageTranscriptionStatus();
                 $doc->setDocumentTranscriptionProgress();
                 $doc->setItemSortWeight();
                 $doc->exportPage($type);
                 if ($flagProtect) {
                     $doc->protectTranscriptionPage();
                 }
             }
         }
         $this->getResponse()->setBody('success');
     } catch (Exception $e) {
         $this->getResponse()->setHttpResponseCode(500);
     }
 }
 /**
  * Delete display profile
  *
  * This action runs when a user deletes a given assignment.
  *
  * @return void
  */
 public function deleteAction()
 {
     $flashMessenger = $this->_helper->FlashMessenger;
     //delete the assignment
     $assign_id = $this->_getParam('assign');
     try {
         if ($assign = get_record_by_id('MmdAssign', $assign_id)) {
             $assign->delete();
             $flashMessenger->addMessage('Assignment deleted successfully', 'success');
         } else {
             $flashMessenger->addMessage('Error deleting assignment. Profile not found.', 'error');
             $this->forward('browse');
         }
     } catch (Exception $e) {
         $flashMessenger->addMessage('Error deleting profile assignment', 'error');
     }
     //forward to browse
     $this->forward('browse');
 }
Example #18
0
 /**
  * Define the form elements.
  *
  *@return void
  */
 private function _registerElements($assign = null)
 {
     //require_once(dirname(dirname(__FILE__)).'/models/Assign.php');
     //require_once(dirname(dirname(__FILE__)).'/models/Table/Assign.php');
     if (is_object($assign)) {
         $this->_assign = $assign;
     } else {
         if (is_numeric($assign)) {
             $this->_assign = get_record_by_id('MmdAssign', $assign);
         }
     }
     if (empty($this->_assign)) {
         $this->_assign = new MmdAssign();
     }
     $assign = $this->_assign;
     $db = get_db();
     $table = $db->getTable('MmdProfile');
     $profiles = $db->getTable('MmdProfile')->findPairsForSelectForm();
     $types = $db->getTable('ItemType')->findPairsForSelectForm();
     $itemTypes = array('0' => 'Assign No Item Type');
     foreach ($types as $key => $value) {
         $itemTypes[$key] = $value;
     }
     $cltns = $db->getTable('Collection')->findPairsForSelectForm();
     $collections = array('0' => 'Assign No Collection');
     foreach ($cltns as $key => $value) {
         $collections[$key] = $value;
     }
     // Profile
     $this->addElement('select', 'profile_id', array('label' => 'Display Profile', 'description' => 'Which display profile would you like to assign?', 'multiOptions' => $profiles, 'value' => (string) $assign->profile_id));
     // Item Type
     $this->addElement('select', 'item_type_id', array('label' => 'Item Type', 'description' => 'If you select an item type here, items of this type will be assigned to display using the selected profile.', 'multiOptions' => $itemTypes, 'value' => (string) $assign->item_type_id));
     // Collection
     $this->addElement('select', 'collection_id', array('label' => 'Collection', 'description' => 'If you select a collection here, items in this collection will be assigned to display using the selected profile.', 'multiOptions' => $collections, 'value' => (string) $assign->collection_id));
     // Filetypes
     $this->addElement('text', 'filetypes', array('label' => 'File Types', 'description' => 'Enter file extensions (without a period) here. Items with attached files with any of these extensions will be assigned to display with the selected profile. (e.g. "jpg,jpeg,png,gif,bmp")', 'value' => (string) $assign->filetypes));
     $checked = $assign->default ? 0 : 1;
     // Default
     $this->addElement('select', 'default', array('label' => 'Default', 'description' => 'Should items assigned to this display profile use it by default, or display normally and include a link to this display?', 'multiOptions' => array('Use display profile by default', 'Link to display profile'), 'value' => $checked));
     if (version_compare(OMEKA_VERSION, '2.2.1') >= 0) {
         $this->addElement('hash', 'csrf_token');
     }
 }
 /**
  * Handle AJAX requests to delete a record.
  */
 public function deleteAction()
 {
     if (!$this->_checkAjax('delete')) {
         return;
     }
     // Handle action.
     try {
         $id = (int) $this->_getParam('id');
         $contributedItem = get_record_by_id('ContributionContributedItem', $id);
         if (!$contributedItem) {
             $this->getResponse()->setHttpResponseCode(400);
             return;
         }
         // The contributed item is automatically deleted when the item is
         // deleted.
         $contributedItem->Item->delete();
     } catch (Exception $e) {
         $this->getResponse()->setHttpResponseCode(500);
     }
 }
function get_type_description_old($search_string)
{
    _log("2 BEFORE GET_DB: ");
    $db = get_db();
    $sql = "\n    SELECT items.id \n    FROM {$db->Item} items \n    JOIN {$db->ElementText} element_texts \n    ON items.id = element_texts.record_id \n    JOIN {$db->Element} elements \n    ON element_texts.element_id = elements.id \n    JOIN {$db->ElementSet} element_sets \n    ON elements.element_set_id = element_sets.id \n    WHERE element_sets.name = 'Dublin Core' \n    AND elements.name = 'Identifier' \n    AND element_texts.text = ?";
    _log("3 BEFORE FETCHING: ");
    $itemIds = $db->fetchAll($sql, $search_string);
    #    $itemIds = array("1000");
    _log("4 AFTER FETCHING: ");
    if (count($itemIds) > 0) {
        //NOG EVEN MEE VERDER STOEIEN
        $found_item = get_record_by_id('item', $itemIds[0]["id"]);
        #        print_pre($found_item);
        #        metadata($found_item, array('Dublin Core', 'Title'));
        $temp_return = metadata($found_item, array('Dublin Core', 'Title')) . " - " . metadata($found_item, array('Dublin Core', 'Description'), array("snippet" => 140));
        #        print_pre($temp_return);
        return $temp_return;
        return "DOES exist";
    }
    return "Type doesn't exist";
}
 /**
  * Get the IIIF manifest for the specified collection.
  *
  * @param Record|integer|null $record Collection
  * @param boolean $asJson Return manifest as object or as a json string.
  * @return Object|string|null. The object or the json string corresponding to the
  * manifest.
  */
 public function iiifCollection($record = null, $asJson = true)
 {
     if (is_null($record)) {
         $record = get_current_record('collection');
     } elseif (is_numeric($record)) {
         $record = get_record_by_id('Collection', (int) $record);
     }
     if (empty($record)) {
         return null;
     }
     $recordClass = get_class($record);
     if ($recordClass != 'Collection') {
         return null;
     }
     $result = $this->_buildManifestCollection($record);
     if ($asJson) {
         return version_compare(phpversion(), '5.4.0', '<') ? json_encode($result) : json_encode($result, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     }
     // Return as array
     return $result;
 }
 /**
  * Front admin page.
  */
 public function indexAction()
 {
     $this->view->files = ReassignFilesPlugin::reassignFiles_getFileNames();
     $defaultLatest = $numExtension = 50;
     $numLatest = isset($_GET["numlatest"]) ? intval($_GET["numlatest"]) : $defaultLatest;
     $numLatest = $numLatest < $defaultLatest ? $defaultLatest : $numLatest;
     $numExtended = $numLatest + $numExtension;
     $extendedUrl = $_SERVER['REDIRECT_URL'] . "?numlatest={$numExtended}";
     $this->view->numLatest = $numLatest;
     $this->view->numExtension = $numExtension;
     $this->view->extendedUrl = $extendedUrl;
     $itemNames = array();
     $sqlDb = get_db();
     $itemSelect = array(-1 => __('Select Below'));
     $query = "\n      SELECT id\n      FROM `{$sqlDb->Items}`\n      ORDER BY modified DESC\n      LIMIT {$numLatest}\n    ";
     $itemIds = $sqlDb->fetchAll($query);
     foreach ($itemIds as $itemId) {
         $curItem = get_record_by_id('Item', $itemId["id"]);
         $itemSelect[$itemId["id"]] = metadata($curItem, array('Dublin Core', 'Title')) . " [#" . $itemId["id"] . "]";
     }
     $this->view->itemSelect = $itemSelect;
 }
 public function unrateAction()
 {
     $db = $this->_helper->db->getTable('Ratings');
     // Allow only AJAX requests.
     if (!$this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->redirector->gotoUrl('/');
     }
     $record_id = $this->_getParam('record_id');
     $user_id = $this->_getParam('user_id');
     // validation needed?
     if (isset($record_id) && isset($user_id)) {
         $this->_helper->db->getTable('Ratings')->removeRating($record_id, $user_id);
     }
     // update AVG rating
     $avgRating = $db->getAvgRating($record_id);
     // Get Item
     $item = get_record_by_id('Item', $record_id);
     // Update the average rating for this item
     $metaData = array('overwriteElementTexts' => true);
     $elementText = array('Ratings' => array('Average Rating' => array(array('text' => $avgRating, 'html' => false))));
     $itemUpdated = update_item($item, $metaData, $elementText);
 }
Example #24
0
 /**
  * Get the IIIF manifest for the specified record.
  *
  * @param Record|integer|null $record
  * @param boolean $asJson Return manifest as object or as a json string.
  * @return Object|string|null. The object or the json string corresponding to the
  * manifest.
  */
 public function iiifManifest($record = null, $asJson = true, $alternative = false, $currentImage = false)
 {
     if (is_null($record)) {
         $record = get_current_record('item');
     } elseif (is_numeric($record)) {
         $record = get_record_by_id('Item', (int) $record);
     }
     if (empty($record)) {
         return null;
     }
     $recordClass = get_class($record);
     if ($recordClass == 'Item') {
         $result = $this->_buildManifestItem($record, $alternative, $currentImage);
     } elseif ($recordClass == 'Collection') {
         return $this->view->iiifCollection($record, $asJson);
     } else {
         return null;
     }
     if ($asJson) {
         return version_compare(phpversion(), '5.4.0', '<') ? json_encode($result) : json_encode($result, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     }
     // Return as array
     return $result;
 }
function get_element_info_dynamic($search_string, $dublin_element_name, $show_elements_dublin = null, $show_elements_itemtype = null)
{
    if (!$show_elements_dublin || !$show_elements_itemtype) {
        $show_elements = array("Title", "Creator", "Publisher");
        #		$show_elements = array("Subgenre");
    }
    $db = get_db();
    $sql = "\n\tSELECT items.id \n\tFROM {$db->Item} items \n\tJOIN {$db->ElementText} element_texts \n\tON items.id = element_texts.record_id \n\tJOIN {$db->Element} elements \n\tON element_texts.element_id = elements.id \n\tJOIN {$db->ElementSet} element_sets \n\tON elements.element_set_id = element_sets.id \n\tAND elements.name = '" . $element_name . "' \n\tAND element_texts.text = ?";
    $itemIds = $db->fetchAll($sql, $search_string);
    if (count($itemIds) == 1) {
        $temp_item = "";
        $found_item = get_record_by_id('item', $itemIds[0]["id"]);
        $temp_return = "<SPAN class='classic'>";
        foreach ($show_elements_dublin as $show_element) {
            $temp_return .= metadata($found_item, array('Dublin Core', $show_element)) . "<br>";
        }
        foreach ($show_elements_itemtype as $show_element) {
            $temp_return .= metadata($found_item, array('Item Type Metadata', $show_element)) . "<br>";
        }
        $temp_return .= "</SPAN>";
        return $temp_return;
    }
    return "no description";
}
/**
 * Add exhibit title to item search filters.
 */
function exhibit_builder_item_search_filters($displayArray, $args)
{
    $request = $args['request_array'];
    if (isset($request['exhibit']) && ($exhibit = get_record_by_id('Exhibit', $request['exhibit']))) {
        $displayArray['exhibit'] = metadata($exhibit, 'title', array('no_escape' => true));
    }
    return $displayArray;
}
 /**
  * Get parent item.
  *
  * @return Omeka_Record The item.
  */
 public function getItem()
 {
     return get_record_by_id('Item', $this->item_id);
 }
 /**
  * Returns the current file.
  */
 public function fetchAction()
 {
     $id = $this->getParam('id');
     $file = get_record_by_id('File', $id);
     if (empty($file)) {
         throw new Omeka_Controller_Exception_404();
     }
     $response = $this->getResponse();
     // Because there is no conversion currently, the format should be
     // checked.
     $format = strtolower($this->getParam('format'));
     if (pathinfo($file->filename, PATHINFO_EXTENSION) != $format) {
         $response->setHttpResponseCode(500);
         $this->view->message = __('The IXIF server encountered an unexpected error that prevented it from fulfilling the request: the requested format is not supported.');
         $this->renderScript('image/error.php');
         return;
     }
     // The source can be a local file or an external one (Amazon S3).
     // A check can be added if the file is local.
     $storageAdapter = Zend_Registry::get('storage')->getAdapter();
     if (get_class($storageAdapter) == 'Omeka_Storage_Adapter_Filesystem') {
         $filepath = FILES_DIR . DIRECTORY_SEPARATOR . $file->getStoragePath('original');
         if (!file_exists($filepath) || filesize($filepath) == 0) {
             $response->setHttpResponseCode(500);
             $this->view->message = __('The IXIF server encountered an unexpected error that prevented it from fulfilling the request: the resulting file is not found.');
             $this->renderScript('image/error.php');
             return;
         }
     }
     // TODO Check if the external url is not empty.
     // Header for CORS, required for access of IXIF.
     $response->setHeader('access-control-allow-origin', '*');
     $response->setHeader('Content-Type', $file->mime_type);
     // TODO This is a local file (normal server): use 200.
     // Redirect (302/307) to the url of the file.
     $fileurl = $file->getWebPath('original');
     $this->_helper->redirector->setGotoUrl($fileurl);
     $this->_helper->redirector->redirectAndExit();
 }
Example #29
0
<form id="batch-edit-form" action="<?php 
echo html_escape(url('items/batch-edit-save'));
?>
" method="post" accept-charset="utf-8">
    <section class="seven columns alpha">
        <fieldset id="item-list" class="panel">
            <h2 class="two columns alpha"><?php 
echo __('Items');
?>
</h2>
            <div class="five columns omega">
                <ul>
                <?php 
$itemCheckboxes = array();
foreach ($itemIds as $id) {
    if (!($item = get_record_by_id('item', $id))) {
        continue;
    }
    $showItemFields = true;
    if (!is_allowed($item, 'edit') || !is_allowed($item, 'delete')) {
        $showItemFields = false;
    }
    $itemCheckboxes[$id] = strip_formatting(metadata($item, array('Dublin Core', 'Title'), array('no_escape' => true)));
    release_object($item);
}
echo '<li>' . $this->formMultiCheckbox('items[]', null, array('checked' => 'checked'), $itemCheckboxes, '</li><li>') . '</li>';
?>
                </ul>
                <p class="explanation"><?php 
echo __('Changes will be applied to checked items.');
?>
Example #30
0
<?php

$pageTitle = __('Advanced Search');
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
if (!empty($params['collection'])) {
    $collection = get_record_by_id('collection', $params['collection']);
}
echo head(array('title' => $pageTitle, 'bodyclass' => 'items advanced-search', 'collection' => @$collection));
?>

<div class="clearfix">
    <nav class="record-nav">
        <?php 
echo include __DIR__ . '/../nav/items.php';
?>
    </nav>
    <h1><?php 
echo $pageTitle;
?>
</h1>
</div>

<?php 
echo $this->partial('items/search-form.php', array('formAttributes' => array('id' => 'advanced-search-form')));
?>

<?php 
echo foot(array('collection' => @$collection));