/** @return items [OmekaItem] Returns an array of OmekaItems that belong to an OmekaCollection. */ public function getItems() { if ($this->items === null) { $this->items = array(); $url = $this->data['items']['url']; $items = Config::getOmeka()->httpGet($url); foreach ($items as $i) { array_push($this->items, new OmekaItem($i)); } } return $this->items; }
/** @return elements [OmekaElement] Returns all elements gathered in an OmekaElementSet. */ public function getElements() { if ($this->elements === null) { $this->elements = array(); $url = $this->data['elements']['url']; $elements = Config::getOmeka()->httpGet($url); foreach ($elements as $eData) { $el = new OmekaElement($eData); $this->elements[$el->getUrl()] = $el; } } return $this->elements; }
/** This file is concerend with displaying a single OmekaItem. To do so, it expects a urn GET parameter to be given. If the urn parameter is missing, errors/noGet.php will be required. If the urn parameter is invalid, errors/invalidUrn.php will be required. Else the page will be displayed as expected. */ require_once 'config.php'; if (!isset($_GET['urn']) || !$_GET['urn']) { require 'errors/noGet.php'; } else { if (is_null(Config::getUserManager()->verify())) { require 'errors/loginRequired.php'; } else { $item = Config::getOmeka()->getItem($_GET['urn']); if ($item === null) { require 'errors/invalidUrn.php'; } else { ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>Viewing item <?php echo $item->getUrn(); ?> </title> <?php require_once 'head.php'; ?> </head>
/** This script crawls the Omeka API to fetch information on items and scans, and inserts this info into the database. It is intended to run this script via cron periodically. */ //First some include magic: //Making sure execution directory is same as this file: chdir(__DIR__); //Adjusting include path so that it works with config.php: set_include_path('..'); require_once '../config.php'; //Restoring include path: restore_include_path(); //Getting the omeka instance: $omeka = Config::getOmeka(); //Making sure we fetch from API: $omeka->setDbUsage(false); //Fetching items: $items = $omeka->getItems(); $iCount = count($items); echo "Fetched {$iCount} Omeka items, storing…\n"; //Storing Items: foreach ($items as $item) { $err = $item->store(); if ($err !== null) { echo "{$err}\n"; } } //Fetching files: $fCount = 0;
<!DOCTYPE HTML> <html lang="en"> <head> <title>Collections of scans</title> <?php require_once 'head.php'; ?> </head> <body> <?php require_once 'navbar.php'; //Gathering items to display: $items = array(); foreach (Config::getOmeka()->getItems() as $i) { if (!$i->shouldDisplay()) { continue; } if ($i->getFileCount() === 0) { continue; } array_push($items, $i); } ?> <div class="container"> <div class="row"> <?php if (count($items) === 0) { ?> <div class="well"> Sorry, we've got nothing to display for you here. It may well be that we can display something if you decide to login.
/** @param $url String @return $item OmekaItem || null Tries to fetch an OmekaItem given its URL. Obeys Omeka->$dbUsage. */ public static function getItemFromUrl($url) { if (Config::getOmeka()->getDbUsage()) { return self::getItemFromDbByUrl($url); } else { if (self::$urlItemMap === null) { self::$urlItemMap = array(); foreach (Config::getOmeka()->getItems() as $item) { self::$urlItemMap[$item->getUrl()] = $item; } } if (array_key_exists($url, self::$urlItemMap)) { return self::$urlItemMap[$url]; } return null; } }
/** Fetches the current representation of an OmekaResource from the server. This makes it especially possible to create a new OmekaResource with only an 'url' field, and fetch the current representation. */ public function update() { $this->data = Config::getOmeka()->httpGet($this->getUrl()); }