Compare commits
No commits in common. '2.x' and '6.x-release' have entirely different histories.
2.x
...
6.x-releas
@ -1,43 +0,0 @@
|
||||
**GitHub Issue**: (link) |
||||
|
||||
* Other Relevant Links (Google Groups discussion, related pull requests, |
||||
Release pull requests, etc.) |
||||
|
||||
# What does this Pull Request do? |
||||
|
||||
A brief description of what the intended result of the PR will be and/or what |
||||
problem it solves. |
||||
|
||||
# What's new? |
||||
A in-depth description of the changes made by this PR. Technical details and |
||||
possible side effects. |
||||
|
||||
* Changes x feature to such that y |
||||
* Added x |
||||
* Removed y |
||||
* Does this change add any new dependencies? |
||||
* Does this change require any other modifications to be made to the repository |
||||
(i.e. Regeneration activity, etc.)? |
||||
* Could this change impact execution of existing code? |
||||
|
||||
# How should this be tested? |
||||
|
||||
A description of what steps someone could take to: |
||||
* Reproduce the problem you are fixing (if applicable) |
||||
* Test that the Pull Request does what is intended. |
||||
* Please be as detailed as possible. |
||||
* Good testing instructions help get your PR completed faster. |
||||
|
||||
# Documentation Status |
||||
|
||||
* Does this change existing behaviour that's currently documented? |
||||
* Does this change require new pages or sections of documentation? |
||||
* Who does this need to be documented for? |
||||
* Associated documentation pull request(s): ___ or documentation issue ___ |
||||
|
||||
# Additional Notes: |
||||
Any additional information that you think would be helpful when reviewing this |
||||
PR. |
||||
|
||||
# Interested parties |
||||
Tag (@ mention) interested parties or, if unsure, @Islandora/committers |
@ -1,125 +0,0 @@
|
||||
name: CI |
||||
|
||||
on: |
||||
push: |
||||
branches: [ 2.x ] |
||||
pull_request: |
||||
branches: [ 2.x ] |
||||
workflow_dispatch: |
||||
|
||||
jobs: |
||||
build: |
||||
env: |
||||
DRUPAL_VERSION: ${{ matrix.drupal-version }} |
||||
SCRIPT_DIR: ${{ github.workspace }}/islandora_ci |
||||
DRUPAL_DIR: /opt/drupal |
||||
PHPUNIT_FILE: ${{ github.workspace }}/build_dir/phpunit.xml |
||||
|
||||
runs-on: ubuntu-latest |
||||
continue-on-error: ${{ matrix.allowed_failure }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
php-versions: ["8.1", "8.2", "8.3"] |
||||
test-suite: ["kernel", "functional", "functional-javascript"] |
||||
drupal-version: ["10.1.x", "10.2.x", "10.3.x-dev"] |
||||
mysql: ["8.0"] |
||||
allowed_failure: [false] |
||||
exclude: |
||||
- php-versions: "8.3" |
||||
drupal-version: "10.1.x" |
||||
|
||||
|
||||
name: PHP ${{ matrix.php-versions }} | drupal ${{ matrix.drupal-version }} | mysql ${{ matrix.mysql }} | test-suite ${{ matrix.test-suite }} |
||||
|
||||
services: |
||||
mysql: |
||||
image: mysql:${{ matrix.mysql }} |
||||
env: |
||||
MYSQL_ALLOW_EMPTY_PASSWORD: yes |
||||
MYSQL_DATABASE: drupal |
||||
ports: |
||||
- 3306:3306 |
||||
activemq: |
||||
image: webcenter/activemq:5.14.3 |
||||
ports: |
||||
- 8161:8161 |
||||
- 61616:61616 |
||||
- 61613:61613 |
||||
|
||||
steps: |
||||
|
||||
- name: Checkout code |
||||
uses: actions/checkout@v4 |
||||
with: |
||||
path: build_dir |
||||
|
||||
- name: Checkout islandora_ci |
||||
uses: actions/checkout@v4 |
||||
with: |
||||
repository: islandora/islandora_ci |
||||
ref: github-actions |
||||
path: islandora_ci |
||||
|
||||
- name: Setup PHP |
||||
uses: shivammathur/setup-php@v2 |
||||
with: |
||||
php-version: ${{ matrix.php-versions }} |
||||
tools: composer:v2 |
||||
|
||||
- name: Setup Mysql client |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get remove -y mysql-client mysql-common |
||||
sudo apt-get install -y mysql-client |
||||
|
||||
- name: Cache Composer dependencies |
||||
uses: actions/cache@v3 |
||||
with: |
||||
path: /tmp/composer-cache |
||||
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} |
||||
|
||||
- name: Setup Drupal |
||||
run: | |
||||
mkdir $DRUPAL_DIR |
||||
$SCRIPT_DIR/travis_setup_drupal.sh |
||||
cd $DRUPAL_DIR |
||||
chmod -R u+w web/sites/default |
||||
mkdir -p web/sites/simpletest/browser_output |
||||
|
||||
- name: Setup composer paths |
||||
run: | |
||||
git -C "$GITHUB_WORKSPACE/build_dir" checkout -b github-testing |
||||
cd $DRUPAL_DIR |
||||
composer config repositories.local path "$GITHUB_WORKSPACE/build_dir" |
||||
composer config minimum-stability dev |
||||
composer require "islandora/islandora:dev-github-testing as dev-2.x" |
||||
|
||||
- name: Install modules |
||||
run: | |
||||
cd $DRUPAL_DIR/web |
||||
drush --uri=127.0.0.1:8282 en -y islandora_audio islandora_breadcrumbs islandora_iiif islandora_image islandora_video islandora_text_extraction_defaults |
||||
|
||||
- name: Copy PHPunit file |
||||
run: cp $PHPUNIT_FILE $DRUPAL_DIR/web/core/phpunit.xml |
||||
|
||||
- name: Test scripts |
||||
run: $SCRIPT_DIR/travis_scripts.sh |
||||
|
||||
- name: Start chromedriver |
||||
if: matrix.test-suite == 'functional-javascript' |
||||
run: |- |
||||
/usr/local/share/chromedriver-linux64/chromedriver \ |
||||
--log-path=/tmp/chromedriver.log \ |
||||
--verbose \ |
||||
--allowed-ips= \ |
||||
--allowed-origins=* & |
||||
|
||||
- name: PHPUNIT tests |
||||
run: | |
||||
cd $DRUPAL_DIR/web/core |
||||
$DRUPAL_DIR/vendor/bin/phpunit --verbose --testsuite "${{ matrix.test-suite }}" |
||||
|
||||
- name: Print chromedriver logs |
||||
if: matrix.test-suite == 'functional-javascript' |
||||
run: cat /tmp/chromedriver.log |
@ -1,26 +0,0 @@
|
||||
name: Mirror and run GitLab CI |
||||
|
||||
on: |
||||
push: |
||||
branches: [2.x] |
||||
tags: '*' |
||||
|
||||
jobs: |
||||
build: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
with: |
||||
fetch-depth: 0 |
||||
- name: Mirror + trigger CI |
||||
uses: SvanBoxel/gitlab-mirror-and-ci-action@master |
||||
with: |
||||
args: "https://git.drupalcode.org/project/islandora" |
||||
env: |
||||
FOLLOW_TAGS: "true" |
||||
FORCE_PUSH: "false" |
||||
GITLAB_HOSTNAME: "git.drupal.org" |
||||
GITLAB_USERNAME: "project_34868_bot" |
||||
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} |
||||
GITLAB_PROJECT_ID: "34868" |
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
@ -1,73 +0,0 @@
|
||||
# Welcome! |
||||
|
||||
If you are reading this document then you are interested in contributing to Islandora 8. All contributions are welcome: use-cases, documentation, code, patches, bug reports, feature requests, etc. You do not need to be a programmer to speak up! |
||||
|
||||
We also have an IRC channel -- #islandora -- on freenode.net. Feel free to hang out there, ask questions, and help others out if you can. |
||||
|
||||
Please note that this project operates under the [Islandora Community Code of Conduct](http://islandora.ca/codeofconduct). By participating in this project you agree to abide by its terms. |
||||
|
||||
## Workflows |
||||
|
||||
The Islandora 8 Tech Call meets each Wednesday at 1:00 PM Eastern, and the Islandora 8 User Call meets every second Thursday at 1:00 PM Eastern. Meeting notes and announcements are posted to the [Islandora community list](https://groups.google.com/forum/#!forum/islandora) and the [Islandora developers list](https://groups.google.com/forum/#!forum/islandora-dev). You can view meeting agendas, notes, and call-in information [here](https://github.com/Islandora/documentation/wiki#islandora-8-tech-calls). Anybody is welcome to join the calls, and add items to the agenda. |
||||
|
||||
### Use cases |
||||
|
||||
If you would like to submit a use case to the Islandora 8 project, please submit an issue [here](https://github.com/Islandora/documentation/issues/new) using the [Use Case template](https://github.com/Islandora/documentation/wiki/Use-Case-template), prepending "Use Case:" to the title of the issue. |
||||
|
||||
### Documentation |
||||
|
||||
You can contribute documentation in two different ways. One way is to create an issue [here](https://github.com/Islandora/documentation/issues/new), prepending "Documentation:" to the title of the issue. Another way is by pull request, which is the same process as [Contribute Code](https://github.com/Islandora/documentation/blob/master/CONTRIBUTING.md#contribute-code). All documentation resides in [`docs`](https://github.com/Islandora/documentation/tree/master/docs). |
||||
|
||||
### Request a new feature |
||||
|
||||
To request a new feature you should [open an issue in the Islandora 8 repository](https://github.com/Islandora/documentation/issues/new) or create a use case (see the _Use cases_ section above), and summarize the desired functionality. Prepend "Enhancement:" if creating an issue on the project repo, and "Use Case:" if creating a use case. |
||||
|
||||
### Report a bug |
||||
|
||||
To report a bug you should [open an issue in the Islandora 8 repository](https://github.com/Islandora/documentation/issues/new) that summarizes the bug. Prepend the label "Bug:" to the title of the issue. |
||||
|
||||
In order to help us understand and fix the bug it would be great if you could provide us with: |
||||
|
||||
1. The steps to reproduce the bug. This includes information about e.g. the Islandora version you were using along with the versions of stack components. |
||||
2. The expected behavior. |
||||
3. The actual, incorrect behavior. |
||||
|
||||
Feel free to search the issue queue for existing issues (aka tickets) that already describe the problem; if there is such a ticket please add your information as a comment. |
||||
|
||||
**If you want to provide a pull along with your bug report:** |
||||
|
||||
That is great! In this case please send us a pull request as described in the section _Create a pull request_ below. |
||||
|
||||
### Contribute code |
||||
|
||||
Before you set out to contribute code you will need to have completed a [Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_cla.pdf) or be covered by a [Corporate Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_ccla.pdf). The signed copy of the license agreement should be sent to <mailto:community@islandora.ca> |
||||
|
||||
_If you are interested in contributing code to Islandora but do not know where to begin:_ |
||||
|
||||
In this case you should [browse open issues](https://github.com/Islandora/documentation/issues) and check out [use cases](https://github.com/Islandora/documentation/labels/use%20case). |
||||
|
||||
If you are contributing Drupal code, it must adhere to [Drupal Coding Standards](https://www.drupal.org/coding-standards); Travis CI will check for this on pull requests. |
||||
|
||||
Contributions to the Islandora codebase should be sent as GitHub pull requests. See section _Create a pull request_ below for details. If there is any problem with the pull request we can work through it using the commenting features of GitHub. |
||||
|
||||
* For _small patches_, feel free to submit pull requests directly for those patches. |
||||
* For _larger code contributions_, please use the following process. The idea behind this process is to prevent any wasted work and catch design issues early on. |
||||
|
||||
1. [Open an issue](https://github.com/Islandora/documentation/issues), prepending "Enhancement:" in the title if a similar issue does not exist already. If a similar issue does exist, then you may consider participating in the work on the existing issue. |
||||
2. Comment on the issue with your plan for implementing the issue. Explain what pieces of the codebase you are going to touch and how everything is going to fit together. |
||||
3. Islandora committers will work with you on the design to make sure you are on the right track. |
||||
4. Implement your issue, create a pull request (see below), and iterate from there. |
||||
|
||||
### Create a pull request |
||||
|
||||
Take a look at [Creating a pull request](https://help.github.com/articles/creating-a-pull-request). In a nutshell you need to: |
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo) this repository to your personal or institutional GitHub account (depending on the CLA you are working under). Be cautious of which branches you work from though (you'll want to base your work off the default branch). See [Fork a repo](https://help.github.com/articles/fork-a-repo) for detailed instructions. |
||||
2. Commit any changes to your fork. |
||||
3. Send a [pull request](https://help.github.com/articles/creating-a-pull-request) using the [pull request template](https://github.com/Islandora/documentation/blob/master/.github/PULL_REQUEST_TEMPLATE.md) to the Islandora GitHub repository that you forked in step 1. If your pull request is related to an existing issue -- for instance, because you reported a [bug/issue](https://github.com/Islandora/documentation/issues) earlier -- prefix the title of your pull request with the corresponding issue number (e.g. `issue-123: ...`). Please also include a reference to the issue in the description of the pull. This can be done by using '#' plus the issue number like so '#123', also try to pick an appropriate name for the branch in which you're issuing the pull request from. |
||||
|
||||
You may want to read [Syncing a fork](https://help.github.com/articles/syncing-a-fork) for instructions on how to keep your fork up to date with the latest changes of the upstream (official) repository. |
||||
|
||||
## License Agreements |
||||
|
||||
The Islandora Foundation requires that contributors complete a [Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_cla.pdf) or be covered by a [Corporate Contributor License Agreement](http://islandora.ca/sites/default/files/islandora_ccla.pdf). The signed copy of the license agreement should be sent to <a href="mailto:community@islandora.ca?Subject=Contributor%20License%20Agreement" target="_top">community@islandora.ca</a>. This license is for your protection as a contributor as well as the protection of the Foundation and its users; it does not change your rights to use your own contributions for any other purpose. A list of current CLAs is kept [here](https://github.com/Islandora/islandora/wiki/Contributor-License-Agreements). |
@ -1,15 +0,0 @@
|
||||
Copyright (C) 2015 The Islandora Foundation and contributors |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or (at |
||||
your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, but |
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program as the file LICENSE.txt; if not, please see |
||||
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
@ -0,0 +1,769 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* |
||||
* Collection Class Class |
||||
*/ |
||||
|
||||
/** |
||||
* This CLASS caches the streams so once you call a getstream once it will always return |
||||
* the same stream as long as you are using the instance of this class. Cached to |
||||
* prevent mutiple hits to fedora. maybe a bit confusing though if this class is used in |
||||
* a different context. |
||||
*/ |
||||
class CollectionClass { |
||||
|
||||
public static $COLLECTION_CLASS_COLLECTION_POLICY_STREAM = 'COLLECTION_POLICY'; |
||||
public static $COLLECTION_CLASS_COLLECTION_VIEW_STREAM = 'COLLECTION_VIEW'; |
||||
private $contentModelStream = NULL; |
||||
private $collectionPolicyStream = NULL; |
||||
private $collectionViewStream = NULL; |
||||
public $collectionObject = NULL; |
||||
|
||||
/** |
||||
* Creates a collection object. Optionally can associate it with a single collection with parameter $pid. |
||||
* |
||||
* @param string $pid The pid of the collection to represent. |
||||
* @return CollectionClass |
||||
*/ |
||||
function __construct($pid = NULL) { |
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
$this->collectionObject = new ObjectHelper(); |
||||
$this->pid = $pid; |
||||
} |
||||
|
||||
public static function getCollectionQuery($pid) { |
||||
$query = self::getCollectionQueryFromStream($pid); |
||||
if (!$query) { |
||||
$query = self::getDefaultCollectionQuery($pid); |
||||
} |
||||
drupal_alter("islandora_collection_query", $query, $pid); |
||||
return $query; |
||||
} |
||||
|
||||
protected static function getCollectionQueryFromStream($pid) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$item = new Fedora_Item($pid); |
||||
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) { |
||||
return $item->get_datastream_dissemination('QUERY'); |
||||
} |
||||
else { |
||||
return FALSE; |
||||
} |
||||
} |
||||
|
||||
protected static function getDefaultCollectionQuery($pid) { |
||||
return 'select $object $title from <#ri> |
||||
where ($object <fedora-model:label> $title |
||||
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '> |
||||
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>) |
||||
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
||||
order by $title'; |
||||
} |
||||
|
||||
/** |
||||
* Gets objects related to this object. Must include offset and limit! |
||||
* |
||||
* Calls self::getRelatedItems() but requires limit and offset. |
||||
* |
||||
* @param $pid string |
||||
* A string containing a Fedora PID. |
||||
* @param $limit |
||||
* An integer |
||||
* @param type $offset |
||||
* @param type $itqlquery |
||||
* @return type |
||||
*/ |
||||
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { |
||||
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset); |
||||
} |
||||
|
||||
/** |
||||
* Gets objects related to this item. |
||||
* |
||||
* Query the resource index using the provided iTQL query. If no query is |
||||
* provided, one should be obtained via self::getCollectionQuery() which |
||||
* grabs the child objects. |
||||
* |
||||
* @param $pid string |
||||
* A string containing a PID which may be substituted into the query, |
||||
* in place of the %parent_collection% placeholder. |
||||
* @param $query_string string |
||||
* An optional iTQL query. |
||||
* @param $limit int |
||||
* An optional integer to limit the number of results returned. |
||||
* @param int $offset |
||||
* An optional integer used to offset the results returned. (Query should |
||||
* involve a sort to maintain consistency. |
||||
* @return string |
||||
* Sparql XML results from the resource index. |
||||
*/ |
||||
function getRelatedItems($pid, $query_string = NULL, $limit = NULL, $offset = NULL) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
if (!fedora_repository_check_perm(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid)) { |
||||
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); |
||||
return ' '; |
||||
} |
||||
|
||||
if ($query_string === NULL) { |
||||
$query_string = self::getCollectionQuery($pid); |
||||
} |
||||
|
||||
// Replace %parent_collection% with the actual collection PID |
||||
$query_string = preg_replace("/\%parent_collection\%/", "<info:fedora/$pid>", $query_string); |
||||
|
||||
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
||||
|
||||
$settings = array( |
||||
'type' => 'tuples', |
||||
'flush' => TRUE, |
||||
'format' => 'Sparql', |
||||
'lang' => 'itql', |
||||
'stream' => 'on', |
||||
'query' => $query_string |
||||
); |
||||
|
||||
if ($limit > 0) { |
||||
$settings['limit'] = $limit; |
||||
} |
||||
if ($offset > 0) { |
||||
$settings['offset'] = $offset; |
||||
} |
||||
|
||||
$url .= '?' . http_build_query($settings, NULL, '&'); |
||||
$content = do_curl($url); |
||||
return $content; |
||||
} |
||||
|
||||
/** |
||||
* get Collection Policy Stream ? |
||||
* @param type $collection_pid |
||||
* @return type |
||||
*/ |
||||
function getCollectionPolicyStream($collection_pid) { |
||||
if ($this->collectionPolicyStream != NULL) { |
||||
return $this->collectionPolicyStream; |
||||
} |
||||
$this->collectionPolicyStream = $this->getStream($collection_pid, CollectionClass :: $COLLECTION_CLASS_COLLECTION_POLICY_STREAM, 0); |
||||
return $this->collectionPolicyStream; |
||||
} |
||||
|
||||
/** |
||||
* get Relationship element ? |
||||
* @param type $collection_pid |
||||
* @return type |
||||
*/ |
||||
function getRelationshipElement($collection_pid) { |
||||
$stream = $this->getCollectionPolicyStream($collection_pid); |
||||
try { |
||||
$xml = new SimpleXMLElement($stream); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Error getting relationship element from policy stream @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return; |
||||
} |
||||
$relationship = $xml->relationship[0]; |
||||
return $relationship; |
||||
} |
||||
|
||||
/** |
||||
* get Collection View Stream ? |
||||
* @param type $collection_pid |
||||
* @return type |
||||
*/ |
||||
function getCollectionViewStream($collection_pid) { |
||||
$this->collectionViewStream = $this->getStream($collection_pid, CollectionClass :: $COLLECTION_CLASS_COLLECTION_VIEW_STREAM, 0); |
||||
return $this->collectionViewStream; |
||||
} |
||||
|
||||
/** |
||||
* get Stream ? |
||||
* @param type $pid |
||||
* @param type $dsid |
||||
* @param type $showError |
||||
* @return type |
||||
*/ |
||||
function getStream($pid, $dsid, $showError = 1) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$item = new fedora_item($pid); |
||||
return isset($item->datastreams[$dsid]) ? $item->get_datastream_dissemination($dsid) : NULL; |
||||
} |
||||
|
||||
/** |
||||
* get Pid name space ? |
||||
* @param type $pid |
||||
* @param type $dsid |
||||
* @return type |
||||
*/ |
||||
function getPidNameSpace($pid, $dsid) { |
||||
$stream = $this->getCollectionPolicyStream($pid); |
||||
try { |
||||
$xml = new SimpleXMLElement($stream); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Error getting PID namespace @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return; |
||||
} |
||||
foreach ($xml->contentmodels->contentmodel as $contentModel) { |
||||
// $contentModelName=strip_tags($contentModel['name']); |
||||
$contentdsid = strip_tags($contentModel->dsid); |
||||
if (strtolower($contentdsid) == strtolower($dsid)) { |
||||
return strip_tags($contentModel->pid_namespace->asXML()); |
||||
} |
||||
} |
||||
drupal_set_message(t('Error getting PID namespace! using collection pid of !pid and content model of !dsid', array('!pid' => $pid, '!dsid' => $dsid)), 'error'); |
||||
return NULL; |
||||
} |
||||
|
||||
/** |
||||
* gets a list of content models from a collection policy |
||||
* @param type $collection_pid |
||||
* @param type $showError |
||||
* @return ContentModel |
||||
*/ |
||||
function getContentModels($collection_pid, $showError = TRUE) { |
||||
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
||||
$collection_stream = $this->getCollectionPolicyStream($collection_pid); |
||||
try { |
||||
$xml = new SimpleXMLElement($collection_stream); |
||||
} catch (Exception $e) { |
||||
if ($showError) { |
||||
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
} |
||||
return NULL; |
||||
} |
||||
foreach ($xml->contentmodels->contentmodel as $content_model) { |
||||
$contentModel = new ContentModel(); |
||||
$contentModel->contentModelDsid = $content_model->dsid; |
||||
$contentModel->contentModelPid = $content_model->pid; |
||||
$contentModel->pidNamespace = $content_model->pidNamespace; |
||||
$contentModel->contentModelName = $content_model['name']; |
||||
$models[] = $contentModel; |
||||
} |
||||
return $models; |
||||
} |
||||
|
||||
/** |
||||
* using the collection policies pid namespace get a new pid by calling fedora' get next pid and appending it to the namespace |
||||
* $pid is the $pid of the content model |
||||
* $dsid is the datastream id of the content model. |
||||
*/ |
||||
function getNextPid($pid, $dsid) { |
||||
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); |
||||
$pidNameSpace = $this->getPidNameSpace($pid, $dsid); |
||||
$pname = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
return Fedora_Item::get_next_pid_in_namespace($pname); |
||||
} |
||||
|
||||
/** |
||||
* gets the form handler file, class and method and returns them in an array |
||||
* |
||||
* @param string $pid The content model PID |
||||
* @param string $dsid The content model DSID |
||||
* @return array The file, class and method name to handle the ingest form. |
||||
*/ |
||||
function getFormHandler($pid, $dsid) { |
||||
$stream = $this->getContentModelStream($pid, $dsid); |
||||
try { |
||||
$xml = new SimpleXMLElement($stream); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Error Getting FormHandler: @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return NULL; |
||||
} |
||||
$formHandler = $xml->ingest_form; |
||||
if ($formHandler != NULL) { |
||||
$handlerDsid = strip_tags($formHandler['dsid']); |
||||
$handlerMethod = strip_tags($formHandler->form_builder_method->form_handler->asXML()); |
||||
$handlerFile = strip_tags($formHandler->form_builder_method->file->asXML()); |
||||
$handlerClass = strip_tags($formHandler->form_builder_method->class_name->asXML()); |
||||
$handlerModule = strip_tags($formHandler->form_builder_method->module->asXML()); |
||||
$returnArray = array(); |
||||
$returnArray['module'] = $handlerModule; |
||||
$returnArray['method'] = $handlerMethod; |
||||
$returnArray['class'] = $handlerClass; |
||||
$returnArray['file'] = $handlerFile; |
||||
return $returnArray; |
||||
} |
||||
|
||||
drupal_set_message(t("Error getting form handler. No handler found for !pid - !dsid", array('!pid' => $pid, '!dsid' => $dsid)), 'error'); |
||||
return NULL; |
||||
} |
||||
|
||||
/** |
||||
* get Allowed Mime Types |
||||
* @param type $contentModelPid |
||||
* @param type $contentModel_dsid |
||||
* @return type |
||||
*/ |
||||
function getAllowedMimeTypes($contentModelPid, $contentModel_dsid) { |
||||
$stream = $this->getContentModelStream($contentModelPid, $contentModel_dsid); |
||||
try { |
||||
$xml = new SimpleXMLElement($stream); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Error getting content model stream for mime types @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return; |
||||
} |
||||
foreach ($xml->mimetypes->type as $type) { |
||||
$types[] = $type; |
||||
} |
||||
return $types; |
||||
} |
||||
|
||||
/** |
||||
* Grabs the rules from the content model stream |
||||
* file the file that has been uploaded |
||||
* |
||||
* @param type $file |
||||
* @param type $mimetype |
||||
* @param type $pid |
||||
* @param type $dsid |
||||
* @return type |
||||
*/ |
||||
function getAndDoRules($file, $mimetype, $pid, $dsid) { |
||||
if (!fedora_repository_check_perm('ingest new fedora objects', $pid)) { |
||||
drupal_set_message(t('You do not have permission to ingest objects.')); |
||||
return FALSE; |
||||
} |
||||
|
||||
$stream = $this->getContentModelStream($pid, $dsid); |
||||
|
||||
try { |
||||
$xml = new SimpleXMLElement($stream); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Error getting content model stream @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return FALSE; |
||||
} |
||||
foreach ($xml->ingest_rules->rule as $rule) { |
||||
foreach ($rule->applies_to as $type) { |
||||
if (!strcmp(trim($type), trim($mimetype))) { |
||||
$methods = $rule->methods->method; |
||||
return $this->callMethods($file, $methods); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* calls the methods defined in the content model rules .xml file stored in a Fedora object |
||||
* |
||||
* @param type $file |
||||
* @param type $methods |
||||
* @return type |
||||
*/ |
||||
function callMethods($file, $methods) { |
||||
foreach ($methods as $method) { |
||||
$phpFile = strip_tags($method->file->asXML()); |
||||
$phpClass = strip_tags($method->class_name->asXML()); |
||||
$phpMethod = strip_tags($method->method_name->asXML()); |
||||
$file_ext = strip_tags($method->modified_files_ext->asXML()); |
||||
$parameters = $method->parameters->parameter; |
||||
$dsid = strip_tags($method->datastream_id); |
||||
$parametersArray = array(); |
||||
if (isset($parameters)) { |
||||
foreach ($parameters as $parameter) { |
||||
$name = strip_tags($parameter['name']); |
||||
$value = strip_tags($parameter->asXML()); |
||||
$parametersArray["$name"] = $value; |
||||
} |
||||
} |
||||
// module_load_include( $phpFile, 'fedora_repository', ' '); |
||||
require_once(drupal_get_path('module', 'fedora_repository') . '/' . $phpFile); |
||||
$thisClass = new $phpClass (); |
||||
$returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); |
||||
if (!$returnValue) { |
||||
drupal_set_message(t('Error! Failed running content model method !m !rv', array('!m' => $phpMethod, '!rv' => $returnValue))); |
||||
return FALSE; |
||||
} |
||||
} |
||||
return TRUE; |
||||
} |
||||
|
||||
/** |
||||
* grabs a xml form definition from a content model and builds |
||||
* the form using drupals forms api |
||||
* |
||||
* @param type $form |
||||
* @param type $form_state |
||||
* @param type $contentModelPid |
||||
* @param type $contentModelDsid |
||||
* @return type |
||||
*/ |
||||
function build_ingest_form(&$form, &$form_state, $contentModelPid, $contentModelDsid) { |
||||
$stream = $this->getContentModelStream($contentModelPid, $contentModelDsid); |
||||
try { |
||||
$xml = new SimpleXMLElement($stream); |
||||
} catch (Exception $e) { |
||||
drupal_set_message(t('Error getting ingest form stream @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return FALSE; |
||||
} |
||||
$docRoot = $_SERVER['DOCUMENT_ROOT']; |
||||
|
||||
$file = (isset($form_state['values']['ingest-file-location']) ? $form_state['values']['ingest-file-location'] : ''); |
||||
// $fullPath = $docRoot . '' . $file; |
||||
$fullpath = $file; |
||||
// $form = array(); |
||||
$form['step'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => (isset($form_state['values']['step']) ? $form_state['values']['step'] : 0) + 1, |
||||
); |
||||
$form['ingest-file-location'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => $file, |
||||
); |
||||
|
||||
$form['content_model_name'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => $contentModelDsid |
||||
); |
||||
$form['models'] = array(//content models available |
||||
'#type' => 'hidden', |
||||
'#value' => $form_state['values']['models'], |
||||
); |
||||
$form['fullpath'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => $fullpath, |
||||
); |
||||
|
||||
$form['#attributes']['enctype'] = 'multipart/form-data'; |
||||
$form['indicator']['ingest-file-location'] = array( |
||||
'#type' => 'file', |
||||
'#title' => t('Upload Document'), |
||||
'#size' => 48, |
||||
'#description' => t('Full text'), |
||||
); |
||||
if ($xml->ingest_form->hide_file_chooser == 'TRUE') { |
||||
$form['indicator']['ingest-file-location']['#type'] = 'hidden'; |
||||
} |
||||
$ingest_form = $xml->ingest_form; //should only be one |
||||
$drupal_module = strip_tags($ingest_form->form_builder_method->module->asXML()); |
||||
if (empty($drupal_module)) { |
||||
$drupal_module = 'fedora_repository'; |
||||
} |
||||
$phpFile = strip_tags($ingest_form->form_builder_method->file->asXML()); |
||||
$phpClass = strip_tags($ingest_form->form_builder_method->class_name->asXML()); |
||||
$phpMethod = strip_tags($ingest_form->form_builder_method->method_name->asXML()); |
||||
$dsid = strip_tags($ingest_form['dsid']); |
||||
// module_load_include('php', 'fedora_repository', $phpFile); |
||||
require_once(drupal_get_path('module', $drupal_module) . '/' . $phpFile); |
||||
$thisClass = new $phpClass (); |
||||
|
||||
return $thisClass->$phpMethod($form, $ingest_form, $form_state['values'], $form_state); |
||||
} |
||||
|
||||
/** |
||||
* this will also create a personal collection for an existing user if they don't have one |
||||
* not using this function currently |
||||
* |
||||
* @param type $user |
||||
* @return type |
||||
*/ |
||||
function createUserCollection(& $user) { |
||||
if (isset($user->fedora_personal_pid)) { |
||||
return; |
||||
} |
||||
$username = array( |
||||
'name' => variable_get('fedora_admin_user', 'fedoraAdmin') |
||||
); |
||||
$admin_user = user_load($username); |
||||
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); |
||||
$connectionHelper = new ConnectionHelper(); |
||||
try { |
||||
$soapClient = $connectionHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M')); |
||||
$pidNameSpace = variable_get('fedora_repository_pid', 'vre:'); |
||||
$pidNameSpace = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); |
||||
$params = array( |
||||
'numPIDs' => '', |
||||
'pidNamespace' => $pidNameSpace |
||||
); |
||||
$object = $soapClient->__soapCall('getNextPID', array( |
||||
$params |
||||
)); |
||||
} catch (exception $e) { |
||||
drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error'); |
||||
return FALSE; |
||||
} |
||||
$pid = implode(get_object_vars($object)); |
||||
$pidNumber = strstr($pid, ":"); |
||||
$pid = $pidNameSpace . ':' . 'USER-' . $user->name . '-' . substr($pidNumber, 1); |
||||
$personal_collection_pid = array( |
||||
'fedora_personal_pid' => $pid |
||||
); |
||||
module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass'); |
||||
$personalCollectionClass = new PersonalCollectionClass(); |
||||
if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { |
||||
drupal_set_message(t("Did not create a personal collection object for !u", array('!u' => $user->name))); |
||||
return FALSE; //creation failed don't save the collection pid in drupal db |
||||
} |
||||
user_save($user, $personal_collection_pid); |
||||
return TRUE; |
||||
} |
||||
|
||||
/** |
||||
* Queries a collection object for an xslt to format how the |
||||
* collection of objects is displayed. |
||||
* |
||||
* @param type $pid |
||||
* @param type $path |
||||
* @param type $canUseDefault |
||||
* @return type |
||||
*/ |
||||
function getXslContent($pid, $path, $canUseDefault = TRUE) { |
||||
module_load_include('inc', 'fedora_repository', 'CollectionClass'); |
||||
$collectionClass = new CollectionClass(); |
||||
$xslContent = $collectionClass->getCollectionViewStream($pid); |
||||
|
||||
//If there's no XSLT from the object, then check if the one which used to exist, does... |
||||
if (!$xslContent && $canUseDefault && file_exists($path . '/xsl/sparql_to_html.xsl')) { |
||||
$xslContent = file_get_contents($path . '/xsl/sparql_to_html.xsl'); |
||||
} |
||||
|
||||
return $xslContent; |
||||
} |
||||
|
||||
/** |
||||
* show field sets ? |
||||
* @global type $base_url |
||||
* @global type $user |
||||
* @param type $page_number |
||||
* @return string |
||||
*/ |
||||
function showFieldSets($page_number) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); |
||||
global $base_url; |
||||
global $user; |
||||
|
||||
$tabset = array(); |
||||
$query = self::getCollectionQuery($this->pid); |
||||
$item = new Fedora_Item($this->pid); |
||||
$results = $this->getRelatedItems($this->pid, $query); |
||||
|
||||
$collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number); |
||||
|
||||
$show_batch_tab = FALSE; |
||||
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); |
||||
|
||||
if (!empty($policy)) { |
||||
$content_models = $policy->getContentModels(); |
||||
} |
||||
if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { |
||||
$show_batch_tab = FALSE; |
||||
} |
||||
|
||||
// Check the form post to see if we are in the middle of an ingest operation. |
||||
$add_selected = ((!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form') || !$collection_items); |
||||
$view_selected = !$add_selected; |
||||
|
||||
$tabset['view_tab'] = array( |
||||
'#type' => 'tabpage', |
||||
'#title' => t('View'), |
||||
'#selected' => $view_selected, |
||||
'#content' => $collection_items, |
||||
'#tab_name' => 'view-tab', |
||||
); |
||||
|
||||
$add_to_collection = $this->getIngestInterface(); |
||||
if (!empty($add_to_collection)) { |
||||
$tabset['add_tab'] = array( |
||||
'#type' => 'tabpage', |
||||
'#title' => t('Add'), |
||||
'#selected' => $add_selected, |
||||
// This will be the content of the tab. |
||||
'#content' => $add_to_collection, |
||||
'#tab_name' => 'add-tab', |
||||
); |
||||
} |
||||
|
||||
return $tabset; |
||||
} |
||||
|
||||
/** |
||||
* get Ingest Interface ?? |
||||
* @global type $base_url |
||||
* @return string |
||||
*/ |
||||
function getIngestInterface() { |
||||
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); |
||||
$collectionPolicyExists = $this->collectionObject->getMimeType($this->pid, CollectionPolicy::getDefaultDSID()); |
||||
if (fedora_repository_check_perm(ObjectHelper :: $INGEST_FEDORA_OBJECTS, $this->pid) && $collectionPolicyExists) { |
||||
if (!empty($collectionPolicyExists)) { |
||||
$allow = TRUE; |
||||
if (module_exists('fedora_fesl')) { |
||||
$allow = fedora_fesl_check_roles($this->pid, 'write'); |
||||
} |
||||
if ($allow) { |
||||
$ingestObject = drupal_get_form('fedora_repository_ingest_form', $this->pid); |
||||
} |
||||
} |
||||
} |
||||
else { |
||||
$ingestObject = ''; |
||||
} |
||||
|
||||
return $ingestObject; |
||||
} |
||||
|
||||
/** |
||||
* Assemble results in a somewhat more logical manner... |
||||
* |
||||
* ... Compared to generating a table in XSLT to contain a list (as |
||||
* renderCollection() used to do/does by default). |
||||
* |
||||
* @param $sparql_results array |
||||
* The array of results as yielded by ObjectHelper::parseSparqlResults() |
||||
* (and those associated functions which make use of it). |
||||
* Each result must contain: |
||||
* - 'object': The PID/URI of the child object. |
||||
* - 'title': A title for the child object. |
||||
* and may contain: |
||||
* - 'thumbnail': URI to a datastream. (will default to the 'TN' stream on the child) |
||||
* @return |
||||
* An array to be passed to drupal_render, containing a pager, an unordered |
||||
* list of items, and another pager. |
||||
*/ |
||||
public static function assembleCollectionView($sparql_results) { |
||||
module_load_include('inc', 'fedora_repository', 'PagerSetup'); |
||||
$per_page = 20; //XXX: Make this configurable. |
||||
$pager_name = 0; |
||||
$total = count($sparql_results); |
||||
$pager_page = fedora_repository_setup_pager($pager_name, $per_page, $total); |
||||
$max_title_length = 60; |
||||
|
||||
$results = array(); |
||||
foreach (array_slice($sparql_results, $per_page * $pager_page, $per_page) as $result) { |
||||
$title = $result['title']; |
||||
$truncated_title = truncate_utf8($title, $max_title_length, TRUE, TRUE, 5); |
||||
$obj_path = "fedora/repository/{$result['object']}"; |
||||
|
||||
//Get a thumbnail |
||||
$tn_path = ($result['thumbnail'] ? |
||||
"fedora/repository/{$result['thumbnail']}": |
||||
"$obj_path/TN"); |
||||
|
||||
$thumbnail = _fedora_repository_render_image($tn_path); |
||||
|
||||
$results[] = array( |
||||
'data' => l($thumbnail, $obj_path, array( |
||||
'html' => TRUE, |
||||
'attributes' => array( |
||||
'class' => 'results-image', |
||||
), |
||||
)) . l($truncated_title, $obj_path, array('attributes' => array('class' => 'results-text'))), |
||||
); |
||||
} |
||||
if (!$results) { |
||||
drupal_set_message(t("No objects in this collection (or bad query).")); |
||||
} |
||||
else { |
||||
$first = $per_page * $pager_page; |
||||
$last = (($total - $first) > $per_page)? |
||||
($first + $per_page): |
||||
$total; |
||||
$results_range_text = t('Results @first to @last of @total', array( |
||||
'@first' => $first + 1, |
||||
'@last' => $last, |
||||
'@total' => $total, |
||||
)); |
||||
|
||||
return array( |
||||
array( |
||||
'#type' => 'markup', |
||||
'#value' => theme('pager', array(), $per_page, $pager_name), |
||||
), |
||||
array( |
||||
'#type' => 'markup', |
||||
'#value' => theme('item_list', $results, $result_range_text, 'ul', array( |
||||
'class' => 'islandora-collection-results-list', |
||||
)) |
||||
), |
||||
array( |
||||
'#type' => 'markup', |
||||
'#value' => theme('pager', array(), $per_page, $pager_name) |
||||
), |
||||
); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* render collection |
||||
* @global type $base_url |
||||
* @param type $content |
||||
* @param type $pid |
||||
* @param type $dsId |
||||
* @param type $collection |
||||
* @param int $pageNumber |
||||
* @return type |
||||
*/ |
||||
function renderCollection($content, $pid, $dsId, $collectionName, $pageNumber = NULL) { |
||||
$path = drupal_get_path('module', 'fedora_repository'); |
||||
global $base_url; |
||||
|
||||
$contentModels = $this->collectionObject->get_content_models_list($pid); |
||||
|
||||
if (empty($collectionName)) { |
||||
$collectionName = menu_get_active_title(); |
||||
} |
||||
|
||||
$xslContent = $this->getXslContent($pid, $path); |
||||
|
||||
$objectList = ''; |
||||
if (isset($content) && $content != FALSE) { |
||||
if (!$xslContent) { //Didn't find an XSLT. |
||||
return drupal_render( |
||||
self::assembleCollectionView( |
||||
$this->collectionObject->parseSparqlResults( |
||||
$content |
||||
) |
||||
) |
||||
); |
||||
} |
||||
else { |
||||
if (!$pageNumber) { |
||||
$pageNumber = 1; |
||||
} |
||||
|
||||
//get collection list and display using xslt------------------------------------------- |
||||
$input = new DomDocument(); |
||||
$input->loadXML(trim($content)); |
||||
$results = $input->getElementsByTagName('result'); |
||||
if ($results->length > 0) { |
||||
try { |
||||
$proc = new XsltProcessor(); |
||||
$options = array( //Could make this the return of a hook? |
||||
'collectionPid' => $pid, |
||||
'collectionTitle' => $collectionName, |
||||
'baseUrl' => $base_url, |
||||
'path' => "$base_url/$path", |
||||
'hitPage' => $pageNumber, |
||||
); |
||||
|
||||
$proc->setParameter('', $options); |
||||
|
||||
$proc->registerPHPFunctions(); |
||||
$xsl = new DomDocument(); |
||||
$xsl->loadXML($xslContent); |
||||
|
||||
$xsl = $proc->importStylesheet($xsl); |
||||
$newdom = $proc->transformToDoc($input); |
||||
|
||||
$objectList = $newdom->saveHTML(); //is the xml transformed to html as defined in the xslt associated with the collection object |
||||
|
||||
if (!$objectList) { |
||||
throw new Exception("Invalid XML."); |
||||
} |
||||
} catch (Exception $e) { |
||||
drupal_set_message(check_plain($e->getMessage()), 'error'); |
||||
return ''; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
else { |
||||
drupal_set_message(t("No objects in this collection (or bad query).")); |
||||
} |
||||
return $objectList; |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,628 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Collection Policy Class |
||||
*/ |
||||
module_load_include('inc', 'fedora_repository', 'XMLDatastream'); |
||||
|
||||
/** |
||||
* Collection Policy class ?? |
||||
*/ |
||||
class CollectionPolicy extends XMLDatastream { |
||||
|
||||
static $SCHEMA_URI = 'http://syn.lib.umanitoba.ca/collection_policy.xsd'; |
||||
static $DEFAULT_DSID = 'COLLECTION_POLICY'; |
||||
private $staging_area = NULL; |
||||
|
||||
/** |
||||
* Gets the default DSID to use for ContentModel datastreams. |
||||
* |
||||
* @return string $default_dsid |
||||
*/ |
||||
static function getDefaultDSID() { |
||||
return variable_get('Islandora_Collection_Policy_DSID', CollectionPolicy::$DEFAULT_DSID); |
||||
} |
||||
|
||||
/** |
||||
* Constructs a new CollectionPolicy object from the specified |
||||
* collection PID. If preFetch is disabled, then Islandora will not get the datastream until needed. |
||||
* (useful when cacheing) |
||||
* Returns FALSE on failure. |
||||
* |
||||
* @param string $pid |
||||
* @param boolean $preFetch = TRUE |
||||
* @return CollectionPolicy $ret |
||||
*/ |
||||
static function loadFromCollection($pid, $preFetch=TRUE) { |
||||
$ret = FALSE; |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
|
||||
try { |
||||
if (self::valid_pid($pid)) { |
||||
$dsid = CollectionPolicy::getDefaultDSID(); |
||||
|
||||
if ($preFetch) { |
||||
$fedoraItem = new Fedora_Item($pid); |
||||
if (array_key_exists($dsid, $fedoraItem->get_datastreams_list_as_array())) { |
||||
$ds = $fedoraItem->get_datastream_dissemination($dsid); |
||||
} |
||||
else { //No collection policy stream (of the default name, anyway) |
||||
return FALSE; |
||||
} |
||||
} |
||||
else { |
||||
$ds = NULL; |
||||
} |
||||
} |
||||
|
||||
if (!empty($ds) || !$preFetch) { |
||||
$ret = new CollectionPolicy($ds, $pid, $dsid); |
||||
} |
||||
} catch (SOAPException $e) { |
||||
$ret = FALSE; |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Ingests a new Collection Policy datastream to the specified |
||||
* PID with the DSID specified. The file should be a valid collection |
||||
* policy XML. Returns FALSE on failure. |
||||
* |
||||
* @param string $pid |
||||
* @param string $name |
||||
* @param string $cpDsid |
||||
* @param string $file |
||||
* @return CollectionPolicy $ret |
||||
*/ |
||||
public static function ingestFromFile($pid, $name, $cpDsid, $file) { |
||||
$ret = FALSE; |
||||
|
||||
if (($cp = self::loadFromCollection($pid, $cpDsid)) === FALSE && file_exists($file)) { |
||||
$cp = new ContentModel(file_get_contents($file), $pid, $cpDsid); |
||||
$rootEl = $cp->xml->getElementsByTagName('collection_policy')->item(0); |
||||
$rootEl->setAttribute('name', $name); |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$fedoraItem = new Fedora_Item($pid); |
||||
$fedoraItem->add_datastream_from_string($cp->dumpXml(), $cpDsid, $name, 'text/xml', 'X'); |
||||
$ret = $cp; |
||||
} |
||||
|
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Ingests a new Collection Policy datastream to the specified |
||||
* PID with the DSID specified. Clones the collection policy from the |
||||
* source collection pid. Returns FALSE on failure. |
||||
* |
||||
* @param string $pid |
||||
* @param string $name |
||||
* @param string $cpDsid |
||||
* @param string $copy_collection_pid |
||||
* @return CollectionPolicy $ret |
||||
*/ |
||||
public static function ingestFromCollection($pid, $name, $cpDsid, $copy_collection_pid) { |
||||
$ret = FALSE; |
||||
|
||||
if (($cp = self::loadFromCollection($pid, $cpDsid)) === FALSE && ($copy_cp = self::loadFromCollection($copy_collection_pid)) !== FALSE && $copy_cp->validate()) { |
||||
$newDom = $copy_cp->xml; |
||||
$rootEl = $newDom->getElementsByTagName('collection_policy')->item(0); |
||||
$rootEl->setAttribute('name', $name); |
||||
|
||||
$cp = new CollectionPolicy($newDom, $pid, $cpDsid); |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$fedoraItem = new Fedora_Item($pid); |
||||
$fedoraItem->add_datastream_from_string($cp->dumpXml(), $cpDsid, $name, 'text/xml', 'X'); |
||||
$ret = $cp; |
||||
} |
||||
|
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Ingests a new minimum Collection Policy datastream to the specified |
||||
* PID with the DSID specified. Initializes the policy with the specified values. |
||||
* Returns FALSE on failure |
||||
* |
||||
* @param string $pid |
||||
* @param string $name |
||||
* @param string $cpDsid |
||||
* @param string $model_pid |
||||
* @param string $model_namespace |
||||
* @param string $relationshiop |
||||
* @param string $searchField |
||||
* @param string $searchValue |
||||
* @return CollectionPolicy $ret |
||||
*/ |
||||
public static function ingestBlankPolicy($pid, $name, $policyDsid, $model_pid, $model_namespace, $relationship, $searchField, $searchValue) { |
||||
$ret = FALSE; |
||||
if (($cp = self::loadFromCollection($pid)) === FALSE) { //removed second, non-existant variable |
||||
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
||||
if (($cm = ContentModel::loadFromModel($model_pid)) !== FALSE && $cm->validate()) { |
||||
$newDom = new DOMDocument('1.0', 'utf-8'); |
||||
$newDom->formatOutput = TRUE; |
||||
$rootEl = $newDom->createElement('collection_policy'); |
||||
$rootEl->setAttribute('name', $name); |
||||
$rootEl->setAttribute('xmlns', self::$XMLNS); |
||||
$rootEl->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); |
||||
$rootEl->setAttribute('xsi:schemaLocation', self::$XMLNS . ' ' . self::$SCHEMA_URI); |
||||
|
||||
$modelsEl = $newDom->createElement('content_models'); |
||||
|
||||
$cmEl = $newDom->createElement('content_model'); |
||||
$cmEl->setAttribute('name', $cm->getName()); |
||||
$cmEl->setAttribute('dsid', $cm->dsid); |
||||
$cmEl->setAttribute('namespace', $model_namespace); |
||||
$cmEl->setAttribute('pid', $cm->pid); |
||||
|
||||
$modelsEl->appendChild($cmEl); |
||||
$rootEl->appendChild($modelsEl); |
||||
|
||||
$relEl = $newDom->createElement('relationship', $relationship); |
||||
$rootEl->appendChild($relEl); |
||||
|
||||
$searchTermsEl = $newDom->createElement('search_terms'); |
||||
$newTermEl = $newDom->createElement('term', $searchValue); |
||||
$newTermEl->setAttribute('field', $searchField); |
||||
$searchTermsEl->appendChild($newTermEl); |
||||
$rootEl->appendChild($searchTermsEl); |
||||
|
||||
$newDom->appendChild($rootEl); |
||||
|
||||
$cp = new CollectionPolicy($newDom, $pid, $policyDsid); |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
|
||||
|
||||
$fedoraItem = new Fedora_Item($pid); |
||||
$fedoraItem->add_datastream_from_string($cp->dumpXml(), $policyDsid, $name, 'text/xml', 'X'); |
||||
$ret = $cp; |
||||
} |
||||
} |
||||
|
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Constructor |
||||
* NOTE: Use the static constructor methods whenever possible. |
||||
* |
||||
* @param string $xmlStr |
||||
* @param string $pid |
||||
* @param string $dsid |
||||
* @return XMLDatastream $cm |
||||
*/ |
||||
public function __construct($xmlStr, $pid = NULL, $dsid = NULL) { |
||||
parent::__construct($xmlStr, $pid, $dsid); |
||||
$this->name = 'Collection Policy'; |
||||
} |
||||
|
||||
/** |
||||
* Attempts to convert from the old XML schema to the new by |
||||
* traversing the XML DOM and building a new DOM. When done |
||||
* $this->xml is replaced by the newly created DOM.. |
||||
* |
||||
* @return void |
||||
*/ |
||||
protected function convertFromOldSchema() { |
||||
if ($this->xml == NULL) { |
||||
$this->fetchXml(); |
||||
} |
||||
$sXml = simplexml_load_string($this->xml->saveXML()); |
||||
$newDom = new DOMDocument('1.0', 'utf-8'); |
||||
$newDom->formatOutput = TRUE; |
||||
|
||||
$rootEl = $newDom->createElement('collection_policy'); |
||||
$rootEl->setAttribute('name', $sXml['name']); |
||||
$rootEl->setAttribute('xmlns', self::$XMLNS); |
||||
$rootEl->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); |
||||
$rootEl->setAttribute('xsi:schemaLocation', self::$XMLNS . ' ' . self::$SCHEMA_URI); |
||||
|
||||
$content_modelsEl = $newDom->createElement('content_models'); |
||||
foreach ($sXml->contentmodels->contentmodel as $contentmodel) { |
||||
$content_modelEl = $newDom->createElement('content_model'); |
||||
$content_modelEl->setAttribute('name', $contentmodel['name']); |
||||
$content_modelEl->setAttribute('dsid', $contentmodel->dsid); |
||||
$content_modelEl->setAttribute('namespace', $contentmodel->pid_namespace); |
||||
$content_modelEl->setAttribute('pid', $contentmodel->pid); |
||||
$content_modelsEl->appendChild($content_modelEl); |
||||
} |
||||
$rootEl->appendChild($content_modelsEl); |
||||
|
||||
$search_termsEl = $newDom->createElement('search_terms'); |
||||
foreach ($sXml->search_terms->term as $term) { |
||||
$termEl = $newDom->createElement('term', $term->value); |
||||
$termEl->setAttribute('field', $term->field); |
||||
if (strval($sXml->search_terms->default) == $term->field) { |
||||
$termEl->setAttribute('default', 'TRUE'); |
||||
} |
||||
$search_termsEl->appendChild($termEl); |
||||
} |
||||
$rootEl->appendChild($search_termsEl); |
||||
|
||||
$relationshipEl = $newDom->createElement('relationship', $sXml->relationship); |
||||
$rootEl->appendChild($relationshipEl); |
||||
|
||||
$newDom->appendChild($rootEl); |
||||
$this->xml = new DOMDocument(); |
||||
$this->xml->loadXML($newDom->saveXml()); |
||||
} |
||||
|
||||
/** |
||||
* Gets the name of the relationship to use |
||||
* for members of this collection. |
||||
* Returns FALSE on failure. |
||||
* |
||||
* @return string $relationship |
||||
*/ |
||||
public function getRelationship() { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$ret = trim($this->xml->getElementsByTagName('relationship')->item(0)->nodeValue); |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Sets the name of the relationship to use |
||||
* for members of this collection. |
||||
* Returns FALSE on failure. |
||||
* |
||||
* @param string $relationship |
||||
* @return boolean $ret |
||||
*/ |
||||
public function setRelationship($relationship) { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$relationshipEl = $this->xml->getElementsByTagName('relationship')->item(0); |
||||
$relationshipEl->nodeValue = trim($relationship); |
||||
$ret = TRUE; |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Gets the path to the staging area to use for this |
||||
* collection. By default recurses to the parent collection |
||||
* if the staging area is undefined |
||||
* |
||||
* @param BOOLEAN $recurse |
||||
* @return string $path |
||||
*/ |
||||
public function getStagingArea($recurse=TRUE) { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
if ($this->staging_area === NULL) { |
||||
$stagingEl = $this->xml->getElementsByTagName('staging_area'); |
||||
|
||||
if ($stagingEl->length > 0) { |
||||
$this->staging_area = trim($stagingEl->item(0)->nodeValue); |
||||
} |
||||
elseif ($recurse) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$item = new Fedora_Item($this->pid); |
||||
$rels = $item->get_relationships(); |
||||
if (count($rels) > 0) { |
||||
foreach ($rels as $rel) { |
||||
$cp = CollectionPolicy::loadFromCollection($rel['object']); |
||||
if ($cp !== FALSE) { |
||||
$this->staging_area = $cp->getStagingArea(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$ret = $this->staging_area; |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Sets the path to the staging area to use for this |
||||
* collection. If specified path is blank (or FALSE) it will |
||||
* remove the staging are path element from the collection policy. |
||||
* |
||||
* @param string $path |
||||
* |
||||
* @return string $relationship |
||||
*/ |
||||
public function setStagingArea($path) { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$rootEl = $this->xml->getElementsByTagName('collection_policy')->item(0); |
||||
$stagingEl = $this->xml->getElementsByTagName('staging_area'); |
||||
if ($stagingEl->length > 0) { |
||||
$stagingEl = $stagingEl->item(0); |
||||
if (trim($path) == '') { |
||||
$rootEl->removeChild($stagingEl); |
||||
} |
||||
else { |
||||
$stagingEl->nodeValue = trim($path); |
||||
} |
||||
} |
||||
elseif (trim($path) != '') { |
||||
$stagingEl = $this->xml->createElement('staging_area', trim($path)); |
||||
$rootEl->appendChild($stagingEl); |
||||
} |
||||
|
||||
$ret = TRUE; |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Gets the next available PID for the |
||||
* content model specified by the DSID |
||||
* parameter. |
||||
* |
||||
* @param string $dsid |
||||
* @return string $nextPid |
||||
*/ |
||||
public function getNextPid($dsid, $content_model = null) { |
||||
$ret = FALSE; |
||||
|
||||
if (self::valid_dsid($dsid) && $this->validate()) { |
||||
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); |
||||
$namespace = FALSE; |
||||
for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) { |
||||
if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid) && (strtolower($content_models->item($i)->getAttribute('pid') == $content_model) || $content_model == null)) { |
||||
$namespace = $content_models->item($i)->getAttribute('namespace'); |
||||
} |
||||
} |
||||
|
||||
$pname = substr($namespace, 0, strpos($namespace, ":")); |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$ret = Fedora_Item::get_next_pid_in_namespace($pname); |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Gets a list of ContentModel objects supported by this collection. |
||||
* |
||||
* @return ContentModel[] $models |
||||
*/ |
||||
function getContentModels() { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
||||
$ret = array(); |
||||
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); |
||||
for ($i = 0; $i < $content_models->length; $i++) { |
||||
$cm = ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'), |
||||
$content_models->item($i)->getAttribute('dsid'), |
||||
$content_models->item($i)->getAttribute('namespace'), |
||||
$content_models->item($i)->getAttribute('name')); |
||||
if ($cm !== FALSE) { |
||||
$ret[] = $cm; |
||||
} |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Gets a list of search terms from the Collection Policy. If asArray is set |
||||
* it will return an associative array with the value, field name, and the default value. |
||||
* If not set, an array of just the values will be returned. If $recurse is TRUE, it will |
||||
* recurseively return the parents search terms if it has none until it returns a set of terms or reaches |
||||
* the top level collection. If $cache is TRUE, it will return a cached version (if available). |
||||
* |
||||
* @param boolean $asArray |
||||
* @param boolean $recurse |
||||
* @param boolean $cache |
||||
* @return string[] $ret |
||||
*/ |
||||
function getSearchTerms($asArray = FALSE, $recurse = FALSE, $cache = FALSE) { |
||||
$ret = FALSE; |
||||
|
||||
if ($cache == TRUE && ($cache = cache_get('collection_policy_search_terms-' . $this->pid)) !== 0) { |
||||
$ret = $cache->data; |
||||
} |
||||
else { |
||||
|
||||
if ($this->xml == NULL) { |
||||
$fedoraItem = new Fedora_Item($this->pid); |
||||
$ds = $fedoraItem->get_datastream_dissemination($this->dsid); |
||||
$this->xml = new DOMDocument(); |
||||
$this->xml->loadXML($ds); |
||||
} |
||||
|
||||
|
||||
if ($this->validate()) { |
||||
$ret = array(); |
||||
$terms = $this->xml->getElementsByTagName('search_terms')->item(0)->getElementsByTagName('term'); |
||||
for ($i = 0; $i < $terms->length; $i++) { |
||||
$default = $terms->item($i)->attributes->getNamedItem('default'); |
||||
$default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'TRUE') : FALSE; |
||||
$ret[] = ($asArray) ? array('value' => $terms->item($i)->nodeValue, |
||||
'field' => $terms->item($i)->getAttribute('field'), |
||||
'default' => $default) : $terms->item($i)->nodeValue; |
||||
} |
||||
|
||||
|
||||
if ($recurse && count($ret) == 0) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$item = new Fedora_Item($this->pid); |
||||
$rels = $item->get_relationships(); |
||||
if (count($rels) > 0) { |
||||
foreach ($rels as $rel) { |
||||
$cp = CollectionPolicy::loadFromCollection($rel['object']); |
||||
if ($cp !== FALSE) { |
||||
$ret = $cp->getSearchTerms($asArray, $recurse); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
cache_set('collection_policy_search_terms-' . $this->pid, $ret, 'cache', time() + 3600); |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Adds a search term to the collection policy. |
||||
* Returns fase on failure. |
||||
* |
||||
* @param string $field |
||||
* @param string $value |
||||
* @return boolean $success |
||||
*/ |
||||
function addTerm($field, $value) { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
||||
$terms = $search_termsEl->getElementsByTagName('term'); |
||||
$found = FALSE; |
||||
for ($i = 0; !$found && $i < $terms->length; $i++) { |
||||
if ($terms->item($i)->getAttribute('field') == $field) { |
||||
$found = TRUE; |
||||
} |
||||
} |
||||
|
||||
if (!$found) { |
||||
$newTermEl = $this->xml->createElement('term', $value); |
||||
$newTermEl->setAttribute('field', $field); |
||||
$search_termsEl->appendChild($newTermEl); |
||||
$ret = TRUE; |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Removes the search term specified by the field parameter from the collection policy. |
||||
* |
||||
* @param string $field |
||||
* @return boolean $success |
||||
*/ |
||||
function removeTerm($field) { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
||||
$terms = $search_termsEl->getElementsByTagName('term'); |
||||
$found = FALSE; |
||||
for ($i = 0; !$found && $i < $terms->length; $i++) { |
||||
if ($terms->item($i)->getAttribute('field') == $field) { |
||||
$found = $terms->item($i); |
||||
} |
||||
} |
||||
|
||||
if ($found !== FALSE) { |
||||
$search_termsEl->removeChild($found); |
||||
$ret = TRUE; |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* setDefaultTerm ?? |
||||
* @param type $field |
||||
* @return boolean |
||||
*/ |
||||
function setDefaultTerm($field) { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
||||
$terms = $search_termsEl->getElementsByTagName('term'); |
||||
$found = FALSE; |
||||
for ($i = 0; !$found && $i < $terms->length; $i++) { |
||||
if ($terms->item($i)->getAttribute('field') == $field) { |
||||
$found = $terms->item($i); |
||||
} |
||||
} |
||||
|
||||
if ($found !== FALSE) { |
||||
for ($i = 0; $i < $terms->length; $i++) |
||||
if ($terms->item($i)->attributes->getNamedItem('default') !== NULL) { |
||||
$terms->item($i)->removeAttribute('default'); |
||||
} |
||||
$found->setAttribute('default', 'TRUE'); |
||||
$ret = TRUE; |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Removes the specified content model from the collection policy. This will only |
||||
* prevent future ingests of the removed model to the collection. $cm should be |
||||
* a valid ContentModel object. Returns FALSE on failure or when the CM was not found in |
||||
* the collection policy. |
||||
* |
||||
* @param ContentModel $cm |
||||
* @return boolean $valid |
||||
*/ |
||||
function removeModel($cm) { |
||||
$ret = FALSE; |
||||
if ($this->validate() && $cm->validate()) { |
||||
$contentmodelsEl = $this->xml->getElementsByTagName('content_models'); |
||||
$models = $contentmodelsEl->item(0)->getElementsByTagName('content_model'); |
||||
$found = FALSE; |
||||
for ($i = 0; $found === FALSE && $i < $models->length; $i++) { |
||||
if ($models->item($i)->getAttribute('pid') == $cm->pid) { |
||||
$found = $models->item($i); |
||||
} |
||||
} |
||||
|
||||
if ($found !== FALSE && $models->length > 1) { |
||||
$contentmodelsEl->item(0)->removeChild($found); |
||||
$ret = TRUE; |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* addModel ?? |
||||
* @param ContentModel $cm |
||||
* @param type $namespace |
||||
* @return type |
||||
*/ |
||||
function addModel($cm, $namespace) { |
||||
$ret = FALSE; |
||||
if (self::valid_pid($namespace) && $this->validate() && $cm->validate()) { |
||||
$contentmodelsEl = $this->xml->getElementsByTagName('content_models'); |
||||
$models = $contentmodelsEl->item(0)->getElementsByTagName('content_model'); |
||||
$found = FALSE; |
||||
for ($i = 0; !$found && $i < $models->length; $i++) { |
||||
if ($models->item($i)->getAttribute('pid') == $cm->pid) |
||||
$found = TRUE; |
||||
} |
||||
|
||||
if (!$found) { |
||||
$cmEl = $this->xml->createElement('content_model'); |
||||
$cmEl->setAttribute('name', $cm->getName()); |
||||
$cmEl->setAttribute('dsid', $cm->dsid); |
||||
$cmEl->setAttribute('namespace', $namespace); |
||||
$cmEl->setAttribute('pid', $cm->pid); |
||||
$contentmodelsEl->item(0)->appendChild($cmEl); |
||||
} |
||||
|
||||
$ret = !$found; |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* getName ?? |
||||
* @return type |
||||
*/ |
||||
function getName() { |
||||
$ret = FALSE; |
||||
if ($this->validate()) { |
||||
$ret = $this->xml->getElementsByTagName('collection_policy')->item(0)->getAttribute('name'); |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,112 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Connection Helper Class |
||||
*/ |
||||
module_load_include('inc', 'ConnectionHelper', ''); |
||||
|
||||
/** |
||||
* Connection Helper Class ?? |
||||
*/ |
||||
class ConnectionHelper { |
||||
|
||||
/** |
||||
* Constructor |
||||
*/ |
||||
function ConnectionHelper() { |
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
||||
} |
||||
|
||||
/** |
||||
* fixURL ?? |
||||
* @param type $url |
||||
* @param type $_name |
||||
* @param type $_pass |
||||
* @return string |
||||
*/ |
||||
function _fixURL($url, $_name, $_pass) { |
||||
if (empty($url)) { |
||||
$url = variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'); |
||||
} |
||||
|
||||
$creds = urlencode($_name) . ':' . urlencode($_pass); |
||||
|
||||
if (strpos($url, 'http://') === 0) { |
||||
$new_url = 'http://' . $creds . '@' . substr($url, 7); |
||||
} |
||||
elseif (strpos($url, 'https://') === 0) { |
||||
$new_url = 'https://' . $creds . '@' . substr($url, 8); |
||||
} |
||||
else { |
||||
drupal_set_message(t('Invalid URL: !url', array('!url' => $url))); |
||||
return NULL; |
||||
} |
||||
|
||||
return $new_url; |
||||
} |
||||
|
||||
/** |
||||
* getSoapClient |
||||
* @global type $user |
||||
* @param type $url |
||||
* @param type $exceptions |
||||
* @return SoapClient |
||||
*/ |
||||
function getSoapClient($url = NULL, $exceptions = TRUE) { |
||||
if (empty($url)) { |
||||
$url = variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'); |
||||
} |
||||
|
||||
global $user; |
||||
if ($user->uid == 0) { |
||||
//anonymous user. We will need an entry in the fedora users.xml file |
||||
//with the appropriate entry for a username of anonymous password of anonymous |
||||
try { |
||||
$client = new SoapClient($url, array( |
||||
'login' => 'anonymous', |
||||
'password' => 'anonymous', |
||||
'exceptions' => $exceptions, |
||||
'authentication' => SOAP_AUTHENTICATION_BASIC |
||||
)); |
||||
} catch (SoapFault $e) { |
||||
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); |
||||
return NULL; |
||||
} |
||||
} |
||||
else { |
||||
try { |
||||
$client = new SoapClient($url, array( |
||||
'login' => $user->name, |
||||
'password' => $user->pass, |
||||
'exceptions' => TRUE, |
||||
'authentication' => SOAP_AUTHENTICATION_BASIC, |
||||
'cache_wsdl' => WSDL_CACHE_MEMORY |
||||
)); |
||||
} catch (SoapFault $e) { |
||||
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); |
||||
return NULL; |
||||
} |
||||
} |
||||
if (isset($_SESSION['islandora_soapcookies'])) { |
||||
|
||||
// just set the cookies |
||||
|
||||
$client->_cookies = ($_SESSION['islandora_soapcookies']); |
||||
} |
||||
else { |
||||
try { |
||||
//we need to make a call to set the cookie this extra call would only happen once per session |
||||
$client->__soapCall('describeRepository', array()); |
||||
$_SESSION['islandora_soapcookies'] = $client->_cookies; |
||||
} catch (exception $e) { |
||||
//connection is tested elsewhere so eat this for now here we just want the cookie |
||||
} |
||||
} |
||||
|
||||
|
||||
return $client; |
||||
} |
||||
|
||||
} |
||||
|
@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE |
||||
Version 2, June 1991 |
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., |
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
Everyone is permitted to copy and distribute verbatim copies |
||||
of this license document, but changing it is not allowed. |
||||
|
||||
Preamble |
||||
|
||||
The licenses for most software are designed to take away your |
||||
freedom to share and change it. By contrast, the GNU General Public |
||||
License is intended to guarantee your freedom to share and change free |
||||
software--to make sure the software is free for all its users. This |
||||
General Public License applies to most of the Free Software |
||||
Foundation's software and to any other program whose authors commit to |
||||
using it. (Some other Free Software Foundation software is covered by |
||||
the GNU Lesser General Public License instead.) You can apply it to |
||||
your programs, too. |
||||
|
||||
When we speak of free software, we are referring to freedom, not |
||||
price. Our General Public Licenses are designed to make sure that you |
||||
have the freedom to distribute copies of free software (and charge for |
||||
this service if you wish), that you receive source code or can get it |
||||
if you want it, that you can change the software or use pieces of it |
||||
in new free programs; and that you know you can do these things. |
||||
|
||||
To protect your rights, we need to make restrictions that forbid |
||||
anyone to deny you these rights or to ask you to surrender the rights. |
||||
These restrictions translate to certain responsibilities for you if you |
||||
distribute copies of the software, or if you modify it. |
||||
|
||||
For example, if you distribute copies of such a program, whether |
||||
gratis or for a fee, you must give the recipients all the rights that |
||||
you have. You must make sure that they, too, receive or can get the |
||||
source code. And you must show them these terms so they know their |
||||
rights. |
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and |
||||
(2) offer you this license which gives you legal permission to copy, |
||||
distribute and/or modify the software. |
||||
|
||||
Also, for each author's protection and ours, we want to make certain |
||||
that everyone understands that there is no warranty for this free |
||||
software. If the software is modified by someone else and passed on, we |
||||
want its recipients to know that what they have is not the original, so |
||||
that any problems introduced by others will not reflect on the original |
||||
authors' reputations. |
||||
|
||||
Finally, any free program is threatened constantly by software |
||||
patents. We wish to avoid the danger that redistributors of a free |
||||
program will individually obtain patent licenses, in effect making the |
||||
program proprietary. To prevent this, we have made it clear that any |
||||
patent must be licensed for everyone's free use or not licensed at all. |
||||
|
||||
The precise terms and conditions for copying, distribution and |
||||
modification follow. |
||||
|
||||
GNU GENERAL PUBLIC LICENSE |
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
||||
|
||||
0. This License applies to any program or other work which contains |
||||
a notice placed by the copyright holder saying it may be distributed |
||||
under the terms of this General Public License. The "Program", below, |
||||
refers to any such program or work, and a "work based on the Program" |
||||
means either the Program or any derivative work under copyright law: |
||||
that is to say, a work containing the Program or a portion of it, |
||||
either verbatim or with modifications and/or translated into another |
||||
language. (Hereinafter, translation is included without limitation in |
||||
the term "modification".) Each licensee is addressed as "you". |
||||
|
||||
Activities other than copying, distribution and modification are not |
||||
covered by this License; they are outside its scope. The act of |
||||
running the Program is not restricted, and the output from the Program |
||||
is covered only if its contents constitute a work based on the |
||||
Program (independent of having been made by running the Program). |
||||
Whether that is true depends on what the Program does. |
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's |
||||
source code as you receive it, in any medium, provided that you |
||||
conspicuously and appropriately publish on each copy an appropriate |
||||
copyright notice and disclaimer of warranty; keep intact all the |
||||
notices that refer to this License and to the absence of any warranty; |
||||
and give any other recipients of the Program a copy of this License |
||||
along with the Program. |
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and |
||||
you may at your option offer warranty protection in exchange for a fee. |
||||
|
||||
2. You may modify your copy or copies of the Program or any portion |
||||
of it, thus forming a work based on the Program, and copy and |
||||
distribute such modifications or work under the terms of Section 1 |
||||
above, provided that you also meet all of these conditions: |
||||
|
||||
a) You must cause the modified files to carry prominent notices |
||||
stating that you changed the files and the date of any change. |
||||
|
||||
b) You must cause any work that you distribute or publish, that in |
||||
whole or in part contains or is derived from the Program or any |
||||
part thereof, to be licensed as a whole at no charge to all third |
||||
parties under the terms of this License. |
||||
|
||||
c) If the modified program normally reads commands interactively |
||||
when run, you must cause it, when started running for such |
||||
interactive use in the most ordinary way, to print or display an |
||||
announcement including an appropriate copyright notice and a |
||||
notice that there is no warranty (or else, saying that you provide |
||||
a warranty) and that users may redistribute the program under |
||||
these conditions, and telling the user how to view a copy of this |
||||
License. (Exception: if the Program itself is interactive but |
||||
does not normally print such an announcement, your work based on |
||||
the Program is not required to print an announcement.) |
||||
|
||||
These requirements apply to the modified work as a whole. If |
||||
identifiable sections of that work are not derived from the Program, |
||||
and can be reasonably considered independent and separate works in |
||||
themselves, then this License, and its terms, do not apply to those |
||||
sections when you distribute them as separate works. But when you |
||||
distribute the same sections as part of a whole which is a work based |
||||
on the Program, the distribution of the whole must be on the terms of |
||||
this License, whose permissions for other licensees extend to the |
||||
entire whole, and thus to each and every part regardless of who wrote it. |
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest |
||||
your rights to work written entirely by you; rather, the intent is to |
||||
exercise the right to control the distribution of derivative or |
||||
collective works based on the Program. |
||||
|
||||
In addition, mere aggregation of another work not based on the Program |
||||
with the Program (or with a work based on the Program) on a volume of |
||||
a storage or distribution medium does not bring the other work under |
||||
the scope of this License. |
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, |
||||
under Section 2) in object code or executable form under the terms of |
||||
Sections 1 and 2 above provided that you also do one of the following: |
||||
|
||||
a) Accompany it with the complete corresponding machine-readable |
||||
source code, which must be distributed under the terms of Sections |
||||
1 and 2 above on a medium customarily used for software interchange; or, |
||||
|
||||
b) Accompany it with a written offer, valid for at least three |
||||
years, to give any third party, for a charge no more than your |
||||
cost of physically performing source distribution, a complete |
||||
machine-readable copy of the corresponding source code, to be |
||||
distributed under the terms of Sections 1 and 2 above on a medium |
||||
customarily used for software interchange; or, |
||||
|
||||
c) Accompany it with the information you received as to the offer |
||||
to distribute corresponding source code. (This alternative is |
||||
allowed only for noncommercial distribution and only if you |
||||
received the program in object code or executable form with such |
||||
an offer, in accord with Subsection b above.) |
||||
|
||||
The source code for a work means the preferred form of the work for |
||||
making modifications to it. For an executable work, complete source |
||||
code means all the source code for all modules it contains, plus any |
||||
associated interface definition files, plus the scripts used to |
||||
control compilation and installation of the executable. However, as a |
||||
special exception, the source code distributed need not include |
||||
anything that is normally distributed (in either source or binary |
||||
form) with the major components (compiler, kernel, and so on) of the |
||||
operating system on which the executable runs, unless that component |
||||
itself accompanies the executable. |
||||
|
||||
If distribution of executable or object code is made by offering |
||||
access to copy from a designated place, then offering equivalent |
||||
access to copy the source code from the same place counts as |
||||
distribution of the source code, even though third parties are not |
||||
compelled to copy the source along with the object code. |
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program |
||||
except as expressly provided under this License. Any attempt |
||||
otherwise to copy, modify, sublicense or distribute the Program is |
||||
void, and will automatically terminate your rights under this License. |
||||
However, parties who have received copies, or rights, from you under |
||||
this License will not have their licenses terminated so long as such |
||||
parties remain in full compliance. |
||||
|
||||
5. You are not required to accept this License, since you have not |
||||
signed it. However, nothing else grants you permission to modify or |
||||
distribute the Program or its derivative works. These actions are |
||||
prohibited by law if you do not accept this License. Therefore, by |
||||
modifying or distributing the Program (or any work based on the |
||||
Program), you indicate your acceptance of this License to do so, and |
||||
all its terms and conditions for copying, distributing or modifying |
||||
the Program or works based on it. |
||||
|
||||
6. Each time you redistribute the Program (or any work based on the |
||||
Program), the recipient automatically receives a license from the |
||||
original licensor to copy, distribute or modify the Program subject to |
||||
these terms and conditions. You may not impose any further |
||||
restrictions on the recipients' exercise of the rights granted herein. |
||||
You are not responsible for enforcing compliance by third parties to |
||||
this License. |
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent |
||||
infringement or for any other reason (not limited to patent issues), |
||||
conditions are imposed on you (whether by court order, agreement or |
||||
otherwise) that contradict the conditions of this License, they do not |
||||
excuse you from the conditions of this License. If you cannot |
||||
distribute so as to satisfy simultaneously your obligations under this |
||||
License and any other pertinent obligations, then as a consequence you |
||||
may not distribute the Program at all. For example, if a patent |
||||
license would not permit royalty-free redistribution of the Program by |
||||
all those who receive copies directly or indirectly through you, then |
||||
the only way you could satisfy both it and this License would be to |
||||
refrain entirely from distribution of the Program. |
||||
|
||||
If any portion of this section is held invalid or unenforceable under |
||||
any particular circumstance, the balance of the section is intended to |
||||
apply and the section as a whole is intended to apply in other |
||||
circumstances. |
||||
|
||||
It is not the purpose of this section to induce you to infringe any |
||||
patents or other property right claims or to contest validity of any |
||||
such claims; this section has the sole purpose of protecting the |
||||
integrity of the free software distribution system, which is |
||||
implemented by public license practices. Many people have made |
||||
generous contributions to the wide range of software distributed |
||||
through that system in reliance on consistent application of that |
||||
system; it is up to the author/donor to decide if he or she is willing |
||||
to distribute software through any other system and a licensee cannot |
||||
impose that choice. |
||||
|
||||
This section is intended to make thoroughly clear what is believed to |
||||
be a consequence of the rest of this License. |
||||
|
||||
8. If the distribution and/or use of the Program is restricted in |
||||
certain countries either by patents or by copyrighted interfaces, the |
||||
original copyright holder who places the Program under this License |
||||
may add an explicit geographical distribution limitation excluding |
||||
those countries, so that distribution is permitted only in or among |
||||
countries not thus excluded. In such case, this License incorporates |
||||
the limitation as if written in the body of this License. |
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions |
||||
of the General Public License from time to time. Such new versions will |
||||
be similar in spirit to the present version, but may differ in detail to |
||||
address new problems or concerns. |
||||
|
||||
Each version is given a distinguishing version number. If the Program |
||||
specifies a version number of this License which applies to it and "any |
||||
later version", you have the option of following the terms and conditions |
||||
either of that version or of any later version published by the Free |
||||
Software Foundation. If the Program does not specify a version number of |
||||
this License, you may choose any version ever published by the Free Software |
||||
Foundation. |
||||
|
||||
10. If you wish to incorporate parts of the Program into other free |
||||
programs whose distribution conditions are different, write to the author |
||||
to ask for permission. For software which is copyrighted by the Free |
||||
Software Foundation, write to the Free Software Foundation; we sometimes |
||||
make exceptions for this. Our decision will be guided by the two goals |
||||
of preserving the free status of all derivatives of our free software and |
||||
of promoting the sharing and reuse of software generally. |
||||
|
||||
NO WARRANTY |
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
||||
REPAIR OR CORRECTION. |
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
||||
POSSIBILITY OF SUCH DAMAGES. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
How to Apply These Terms to Your New Programs |
||||
|
||||
If you develop a new program, and you want it to be of the greatest |
||||
possible use to the public, the best way to achieve this is to make it |
||||
free software which everyone can redistribute and change under these terms. |
||||
|
||||
To do so, attach the following notices to the program. It is safest |
||||
to attach them to the start of each source file to most effectively |
||||
convey the exclusion of warranty; and each file should have at least |
||||
the "copyright" line and a pointer to where the full notice is found. |
||||
|
||||
<one line to give the program's name and a brief idea of what it does.> |
||||
Copyright (C) <year> <name of author> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 2 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License along |
||||
with this program; if not, write to the Free Software Foundation, Inc., |
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
|
||||
Also add information on how to contact you by electronic and paper mail. |
||||
|
||||
If the program is interactive, make it output a short notice like this |
||||
when it starts in an interactive mode: |
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author |
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
||||
This is free software, and you are welcome to redistribute it |
||||
under certain conditions; type `show c' for details. |
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate |
||||
parts of the General Public License. Of course, the commands you use may |
||||
be called something other than `show w' and `show c'; they could even be |
||||
mouse-clicks or menu items--whatever suits your program. |
||||
|
||||
You should also get your employer (if you work as a programmer) or your |
||||
school, if any, to sign a "copyright disclaimer" for the program, if |
||||
necessary. Here is a sample; alter the names: |
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program |
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker. |
||||
|
||||
<signature of Ty Coon>, 1 April 1989 |
||||
Ty Coon, President of Vice |
||||
|
||||
This General Public License does not permit incorporating your program into |
||||
proprietary programs. If your program is a subroutine library, you may |
||||
consider it more useful to permit linking proprietary applications with the |
||||
library. If this is what you want to do, use the GNU Lesser General |
||||
Public License instead of this License. |
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE |
||||
Version 3, 29 June 2007 |
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
||||
Everyone is permitted to copy and distribute verbatim copies |
||||
of this license document, but changing it is not allowed. |
||||
|
||||
Preamble |
||||
|
||||
The GNU General Public License is a free, copyleft license for |
||||
software and other kinds of works. |
||||
|
||||
The licenses for most software and other practical works are designed |
||||
to take away your freedom to share and change the works. By contrast, |
||||
the GNU General Public License is intended to guarantee your freedom to |
||||
share and change all versions of a program--to make sure it remains free |
||||
software for all its users. We, the Free Software Foundation, use the |
||||
GNU General Public License for most of our software; it applies also to |
||||
any other work released this way by its authors. You can apply it to |
||||
your programs, too. |
||||
|
||||
When we speak of free software, we are referring to freedom, not |
||||
price. Our General Public Licenses are designed to make sure that you |
||||
have the freedom to distribute copies of free software (and charge for |
||||
them if you wish), that you receive source code or can get it if you |
||||
want it, that you can change the software or use pieces of it in new |
||||
free programs, and that you know you can do these things. |
||||
|
||||
To protect your rights, we need to prevent others from denying you |
||||
these rights or asking you to surrender the rights. Therefore, you have |
||||
certain responsibilities if you distribute copies of the software, or if |
||||
you modify it: responsibilities to respect the freedom of others. |
||||
|
||||
For example, if you distribute copies of such a program, whether |
||||
gratis or for a fee, you must pass on to the recipients the same |
||||
freedoms that you received. You must make sure that they, too, receive |
||||
or can get the source code. And you must show them these terms so they |
||||
know their rights. |
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: |
||||
(1) assert copyright on the software, and (2) offer you this License |
||||
giving you legal permission to copy, distribute and/or modify it. |
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains |
||||
that there is no warranty for this free software. For both users' and |
||||
authors' sake, the GPL requires that modified versions be marked as |
||||
changed, so that their problems will not be attributed erroneously to |
||||
authors of previous versions. |
||||
|
||||
Some devices are designed to deny users access to install or run |
||||
modified versions of the software inside them, although the manufacturer |
||||
can do so. This is fundamentally incompatible with the aim of |
||||
protecting users' freedom to change the software. The systematic |
||||
pattern of such abuse occurs in the area of products for individuals to |
||||
use, which is precisely where it is most unacceptable. Therefore, we |
||||
have designed this version of the GPL to prohibit the practice for those |
||||
products. If such problems arise substantially in other domains, we |
||||
stand ready to extend this provision to those domains in future versions |
||||
of the GPL, as needed to protect the freedom of users. |
||||
|
||||
Finally, every program is threatened constantly by software patents. |
||||
States should not allow patents to restrict development and use of |
||||
software on general-purpose computers, but in those that do, we wish to |
||||
avoid the special danger that patents applied to a free program could |
||||
make it effectively proprietary. To prevent this, the GPL assures that |
||||
patents cannot be used to render the program non-free. |
||||
|
||||
The precise terms and conditions for copying, distribution and |
||||
modification follow. |
||||
|
||||
TERMS AND CONDITIONS |
||||
|
||||
0. Definitions. |
||||
|
||||
"This License" refers to version 3 of the GNU General Public License. |
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of |
||||
works, such as semiconductor masks. |
||||
|
||||
"The Program" refers to any copyrightable work licensed under this |
||||
License. Each licensee is addressed as "you". "Licensees" and |
||||
"recipients" may be individuals or organizations. |
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work |
||||
in a fashion requiring copyright permission, other than the making of an |
||||
exact copy. The resulting work is called a "modified version" of the |
||||
earlier work or a work "based on" the earlier work. |
||||
|
||||
A "covered work" means either the unmodified Program or a work based |
||||
on the Program. |
||||
|
||||
To "propagate" a work means to do anything with it that, without |
||||
permission, would make you directly or secondarily liable for |
||||
infringement under applicable copyright law, except executing it on a |
||||
computer or modifying a private copy. Propagation includes copying, |
||||
distribution (with or without modification), making available to the |
||||
public, and in some countries other activities as well. |
||||
|
||||
To "convey" a work means any kind of propagation that enables other |
||||
parties to make or receive copies. Mere interaction with a user through |
||||
a computer network, with no transfer of a copy, is not conveying. |
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" |
||||
to the extent that it includes a convenient and prominently visible |
||||
feature that (1) displays an appropriate copyright notice, and (2) |
||||
tells the user that there is no warranty for the work (except to the |
||||
extent that warranties are provided), that licensees may convey the |
||||
work under this License, and how to view a copy of this License. If |
||||
the interface presents a list of user commands or options, such as a |
||||
menu, a prominent item in the list meets this criterion. |
||||
|
||||
1. Source Code. |
||||
|
||||
The "source code" for a work means the preferred form of the work |
||||
for making modifications to it. "Object code" means any non-source |
||||
form of a work. |
||||
|
||||
A "Standard Interface" means an interface that either is an official |
||||
standard defined by a recognized standards body, or, in the case of |
||||
interfaces specified for a particular programming language, one that |
||||
is widely used among developers working in that language. |
||||
|
||||
The "System Libraries" of an executable work include anything, other |
||||
than the work as a whole, that (a) is included in the normal form of |
||||
packaging a Major Component, but which is not part of that Major |
||||
Component, and (b) serves only to enable use of the work with that |
||||
Major Component, or to implement a Standard Interface for which an |
||||
implementation is available to the public in source code form. A |
||||
"Major Component", in this context, means a major essential component |
||||
(kernel, window system, and so on) of the specific operating system |
||||
(if any) on which the executable work runs, or a compiler used to |
||||
produce the work, or an object code interpreter used to run it. |
||||
|
||||
The "Corresponding Source" for a work in object code form means all |
||||
the source code needed to generate, install, and (for an executable |
||||
work) run the object code and to modify the work, including scripts to |
||||
control those activities. However, it does not include the work's |
||||
System Libraries, or general-purpose tools or generally available free |
||||
programs which are used unmodified in performing those activities but |
||||
which are not part of the work. For example, Corresponding Source |
||||
includes interface definition files associated with source files for |
||||
the work, and the source code for shared libraries and dynamically |
||||
linked subprograms that the work is specifically designed to require, |
||||
such as by intimate data communication or control flow between those |
||||
subprograms and other parts of the work. |
||||
|
||||
The Corresponding Source need not include anything that users |
||||
can regenerate automatically from other parts of the Corresponding |
||||
Source. |
||||
|
||||
The Corresponding Source for a work in source code form is that |
||||
same work. |
||||
|
||||
2. Basic Permissions. |
||||
|
||||
All rights granted under this License are granted for the term of |
||||
copyright on the Program, and are irrevocable provided the stated |
||||
conditions are met. This License explicitly affirms your unlimited |
||||
permission to run the unmodified Program. The output from running a |
||||
covered work is covered by this License only if the output, given its |
||||
content, constitutes a covered work. This License acknowledges your |
||||
rights of fair use or other equivalent, as provided by copyright law. |
||||
|
||||
You may make, run and propagate covered works that you do not |
||||
convey, without conditions so long as your license otherwise remains |
||||
in force. You may convey covered works to others for the sole purpose |
||||
of having them make modifications exclusively for you, or provide you |
||||
with facilities for running those works, provided that you comply with |
||||
the terms of this License in conveying all material for which you do |
||||
not control copyright. Those thus making or running the covered works |
||||
for you must do so exclusively on your behalf, under your direction |
||||
and control, on terms that prohibit them from making any copies of |
||||
your copyrighted material outside their relationship with you. |
||||
|
||||
Conveying under any other circumstances is permitted solely under |
||||
the conditions stated below. Sublicensing is not allowed; section 10 |
||||
makes it unnecessary. |
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
||||
|
||||
No covered work shall be deemed part of an effective technological |
||||
measure under any applicable law fulfilling obligations under article |
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or |
||||
similar laws prohibiting or restricting circumvention of such |
||||
measures. |
||||
|
||||
When you convey a covered work, you waive any legal power to forbid |
||||
circumvention of technological measures to the extent such circumvention |
||||
is effected by exercising rights under this License with respect to |
||||
the covered work, and you disclaim any intention to limit operation or |
||||
modification of the work as a means of enforcing, against the work's |
||||
users, your or third parties' legal rights to forbid circumvention of |
||||
technological measures. |
||||
|
||||
4. Conveying Verbatim Copies. |
||||
|
||||
You may convey verbatim copies of the Program's source code as you |
||||
receive it, in any medium, provided that you conspicuously and |
||||
appropriately publish on each copy an appropriate copyright notice; |
||||
keep intact all notices stating that this License and any |
||||
non-permissive terms added in accord with section 7 apply to the code; |
||||
keep intact all notices of the absence of any warranty; and give all |
||||
recipients a copy of this License along with the Program. |
||||
|
||||
You may charge any price or no price for each copy that you convey, |
||||
and you may offer support or warranty protection for a fee. |
||||
|
||||
5. Conveying Modified Source Versions. |
||||
|
||||
You may convey a work based on the Program, or the modifications to |
||||
produce it from the Program, in the form of source code under the |
||||
terms of section 4, provided that you also meet all of these conditions: |
||||
|
||||
a) The work must carry prominent notices stating that you modified |
||||
it, and giving a relevant date. |
||||
|
||||
b) The work must carry prominent notices stating that it is |
||||
released under this License and any conditions added under section |
||||
7. This requirement modifies the requirement in section 4 to |
||||
"keep intact all notices". |
||||
|
||||
c) You must license the entire work, as a whole, under this |
||||
License to anyone who comes into possession of a copy. This |
||||
License will therefore apply, along with any applicable section 7 |
||||
additional terms, to the whole of the work, and all its parts, |
||||
regardless of how they are packaged. This License gives no |
||||
permission to license the work in any other way, but it does not |
||||
invalidate such permission if you have separately received it. |
||||
|
||||
d) If the work has interactive user interfaces, each must display |
||||
Appropriate Legal Notices; however, if the Program has interactive |
||||
interfaces that do not display Appropriate Legal Notices, your |
||||
work need not make them do so. |
||||
|
||||
A compilation of a covered work with other separate and independent |
||||
works, which are not by their nature extensions of the covered work, |
||||
and which are not combined with it such as to form a larger program, |
||||
in or on a volume of a storage or distribution medium, is called an |
||||
"aggregate" if the compilation and its resulting copyright are not |
||||
used to limit the access or legal rights of the compilation's users |
||||
beyond what the individual works permit. Inclusion of a covered work |
||||
in an aggregate does not cause this License to apply to the other |
||||
parts of the aggregate. |
||||
|
||||
6. Conveying Non-Source Forms. |
||||
|
||||
You may convey a covered work in object code form under the terms |
||||
of sections 4 and 5, provided that you also convey the |
||||
machine-readable Corresponding Source under the terms of this License, |
||||
in one of these ways: |
||||
|
||||
a) Convey the object code in, or embodied in, a physical product |
||||
(including a physical distribution medium), accompanied by the |
||||
Corresponding Source fixed on a durable physical medium |
||||
customarily used for software interchange. |
||||
|
||||
b) Convey the object code in, or embodied in, a physical product |
||||
(including a physical distribution medium), accompanied by a |
||||
written offer, valid for at least three years and valid for as |
||||
long as you offer spare parts or customer support for that product |
||||
model, to give anyone who possesses the object code either (1) a |
||||
copy of the Corresponding Source for all the software in the |
||||
product that is covered by this License, on a durable physical |
||||
medium customarily used for software interchange, for a price no |
||||
more than your reasonable cost of physically performing this |
||||
conveying of source, or (2) access to copy the |
||||
Corresponding Source from a network server at no charge. |
||||
|
||||
c) Convey individual copies of the object code with a copy of the |
||||
written offer to provide the Corresponding Source. This |
||||
alternative is allowed only occasionally and noncommercially, and |
||||
only if you received the object code with such an offer, in accord |
||||
with subsection 6b. |
||||
|
||||
d) Convey the object code by offering access from a designated |
||||
place (gratis or for a charge), and offer equivalent access to the |
||||
Corresponding Source in the same way through the same place at no |
||||
further charge. You need not require recipients to copy the |
||||
Corresponding Source along with the object code. If the place to |
||||
copy the object code is a network server, the Corresponding Source |
||||
may be on a different server (operated by you or a third party) |
||||
that supports equivalent copying facilities, provided you maintain |
||||
clear directions next to the object code saying where to find the |
||||
Corresponding Source. Regardless of what server hosts the |
||||
Corresponding Source, you remain obligated to ensure that it is |
||||
available for as long as needed to satisfy these requirements. |
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided |
||||
you inform other peers where the object code and Corresponding |
||||
Source of the work are being offered to the general public at no |
||||
charge under subsection 6d. |
||||
|
||||
A separable portion of the object code, whose source code is excluded |
||||
from the Corresponding Source as a System Library, need not be |
||||
included in conveying the object code work. |
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any |
||||
tangible personal property which is normally used for personal, family, |
||||
or household purposes, or (2) anything designed or sold for incorporation |
||||
into a dwelling. In determining whether a product is a consumer product, |
||||
doubtful cases shall be resolved in favor of coverage. For a particular |
||||
product received by a particular user, "normally used" refers to a |
||||
typical or common use of that class of product, regardless of the status |
||||
of the particular user or of the way in which the particular user |
||||
actually uses, or expects or is expected to use, the product. A product |
||||
is a consumer product regardless of whether the product has substantial |
||||
commercial, industrial or non-consumer uses, unless such uses represent |
||||
the only significant mode of use of the product. |
||||
|
||||
"Installation Information" for a User Product means any methods, |
||||
procedures, authorization keys, or other information required to install |
||||
and execute modified versions of a covered work in that User Product from |
||||
a modified version of its Corresponding Source. The information must |
||||
suffice to ensure that the continued functioning of the modified object |
||||
code is in no case prevented or interfered with solely because |
||||
modification has been made. |
||||
|
||||
If you convey an object code work under this section in, or with, or |
||||
specifically for use in, a User Product, and the conveying occurs as |
||||
part of a transaction in which the right of possession and use of the |
||||
User Product is transferred to the recipient in perpetuity or for a |
||||
fixed term (regardless of how the transaction is characterized), the |
||||
Corresponding Source conveyed under this section must be accompanied |
||||
by the Installation Information. But this requirement does not apply |
||||
if neither you nor any third party retains the ability to install |
||||
modified object code on the User Product (for example, the work has |
||||
been installed in ROM). |
||||
|
||||
The requirement to provide Installation Information does not include a |
||||
requirement to continue to provide support service, warranty, or updates |
||||
for a work that has been modified or installed by the recipient, or for |
||||
the User Product in which it has been modified or installed. Access to a |
||||
network may be denied when the modification itself materially and |
||||
adversely affects the operation of the network or violates the rules and |
||||
protocols for communication across the network. |
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, |
||||
in accord with this section must be in a format that is publicly |
||||
documented (and with an implementation available to the public in |
||||
source code form), and must require no special password or key for |
||||
unpacking, reading or copying. |
||||
|
||||
7. Additional Terms. |
||||
|
||||
"Additional permissions" are terms that supplement the terms of this |
||||
License by making exceptions from one or more of its conditions. |
||||
Additional permissions that are applicable to the entire Program shall |
||||
be treated as though they were included in this License, to the extent |
||||
that they are valid under applicable law. If additional permissions |
||||
apply only to part of the Program, that part may be used separately |
||||
under those permissions, but the entire Program remains governed by |
||||
this License without regard to the additional permissions. |
||||
|
||||
When you convey a copy of a covered work, you may at your option |
||||
remove any additional permissions from that copy, or from any part of |
||||
it. (Additional permissions may be written to require their own |
||||
removal in certain cases when you modify the work.) You may place |
||||
additional permissions on material, added by you to a covered work, |
||||
for which you have or can give appropriate copyright permission. |
||||
|
||||
Notwithstanding any other provision of this License, for material you |
||||
add to a covered work, you may (if authorized by the copyright holders of |
||||
that material) supplement the terms of this License with terms: |
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the |
||||
terms of sections 15 and 16 of this License; or |
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or |
||||
author attributions in that material or in the Appropriate Legal |
||||
Notices displayed by works containing it; or |
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or |
||||
requiring that modified versions of such material be marked in |
||||
reasonable ways as different from the original version; or |
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or |
||||
authors of the material; or |
||||
|
||||
e) Declining to grant rights under trademark law for use of some |
||||
trade names, trademarks, or service marks; or |
||||
|
||||
f) Requiring indemnification of licensors and authors of that |
||||
material by anyone who conveys the material (or modified versions of |
||||
it) with contractual assumptions of liability to the recipient, for |
||||
any liability that these contractual assumptions directly impose on |
||||
those licensors and authors. |
||||
|
||||
All other non-permissive additional terms are considered "further |
||||
restrictions" within the meaning of section 10. If the Program as you |
||||
received it, or any part of it, contains a notice stating that it is |
||||
governed by this License along with a term that is a further |
||||
restriction, you may remove that term. If a license document contains |
||||
a further restriction but permits relicensing or conveying under this |
||||
License, you may add to a covered work material governed by the terms |
||||
of that license document, provided that the further restriction does |
||||
not survive such relicensing or conveying. |
||||
|
||||
If you add terms to a covered work in accord with this section, you |
||||
must place, in the relevant source files, a statement of the |
||||
additional terms that apply to those files, or a notice indicating |
||||
where to find the applicable terms. |
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the |
||||
form of a separately written license, or stated as exceptions; |
||||
the above requirements apply either way. |
||||
|
||||
8. Termination. |
||||
|
||||
You may not propagate or modify a covered work except as expressly |
||||
provided under this License. Any attempt otherwise to propagate or |
||||
modify it is void, and will automatically terminate your rights under |
||||
this License (including any patent licenses granted under the third |
||||
paragraph of section 11). |
||||
|
||||
However, if you cease all violation of this License, then your |
||||
license from a particular copyright holder is reinstated (a) |
||||
provisionally, unless and until the copyright holder explicitly and |
||||
finally terminates your license, and (b) permanently, if the copyright |
||||
holder fails to notify you of the violation by some reasonable means |
||||
prior to 60 days after the cessation. |
||||
|
||||
Moreover, your license from a particular copyright holder is |
||||
reinstated permanently if the copyright holder notifies you of the |
||||
violation by some reasonable means, this is the first time you have |
||||
received notice of violation of this License (for any work) from that |
||||
copyright holder, and you cure the violation prior to 30 days after |
||||
your receipt of the notice. |
||||
|
||||
Termination of your rights under this section does not terminate the |
||||
licenses of parties who have received copies or rights from you under |
||||
this License. If your rights have been terminated and not permanently |
||||
reinstated, you do not qualify to receive new licenses for the same |
||||
material under section 10. |
||||
|
||||
9. Acceptance Not Required for Having Copies. |
||||
|
||||
You are not required to accept this License in order to receive or |
||||
run a copy of the Program. Ancillary propagation of a covered work |
||||
occurring solely as a consequence of using peer-to-peer transmission |
||||
to receive a copy likewise does not require acceptance. However, |
||||
nothing other than this License grants you permission to propagate or |
||||
modify any covered work. These actions infringe copyright if you do |
||||
not accept this License. Therefore, by modifying or propagating a |
||||
covered work, you indicate your acceptance of this License to do so. |
||||
|
||||
10. Automatic Licensing of Downstream Recipients. |
||||
|
||||
Each time you convey a covered work, the recipient automatically |
||||
receives a license from the original licensors, to run, modify and |
||||
propagate that work, subject to this License. You are not responsible |
||||
for enforcing compliance by third parties with this License. |
||||
|
||||
An "entity transaction" is a transaction transferring control of an |
||||
organization, or substantially all assets of one, or subdividing an |
||||
organization, or merging organizations. If propagation of a covered |
||||
work results from an entity transaction, each party to that |
||||
transaction who receives a copy of the work also receives whatever |
||||
licenses to the work the party's predecessor in interest had or could |
||||
give under the previous paragraph, plus a right to possession of the |
||||
Corresponding Source of the work from the predecessor in interest, if |
||||
the predecessor has it or can get it with reasonable efforts. |
||||
|
||||
You may not impose any further restrictions on the exercise of the |
||||
rights granted or affirmed under this License. For example, you may |
||||
not impose a license fee, royalty, or other charge for exercise of |
||||
rights granted under this License, and you may not initiate litigation |
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that |
||||
any patent claim is infringed by making, using, selling, offering for |
||||
sale, or importing the Program or any portion of it. |
||||
|
||||
11. Patents. |
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this |
||||
License of the Program or a work on which the Program is based. The |
||||
work thus licensed is called the contributor's "contributor version". |
||||
|
||||
A contributor's "essential patent claims" are all patent claims |
||||
owned or controlled by the contributor, whether already acquired or |
||||
hereafter acquired, that would be infringed by some manner, permitted |
||||
by this License, of making, using, or selling its contributor version, |
||||
but do not include claims that would be infringed only as a |
||||
consequence of further modification of the contributor version. For |
||||
purposes of this definition, "control" includes the right to grant |
||||
patent sublicenses in a manner consistent with the requirements of |
||||
this License. |
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free |
||||
patent license under the contributor's essential patent claims, to |
||||
make, use, sell, offer for sale, import and otherwise run, modify and |
||||
propagate the contents of its contributor version. |
||||
|
||||
In the following three paragraphs, a "patent license" is any express |
||||
agreement or commitment, however denominated, not to enforce a patent |
||||
(such as an express permission to practice a patent or covenant not to |
||||
sue for patent infringement). To "grant" such a patent license to a |
||||
party means to make such an agreement or commitment not to enforce a |
||||
patent against the party. |
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, |
||||
and the Corresponding Source of the work is not available for anyone |
||||
to copy, free of charge and under the terms of this License, through a |
||||
publicly available network server or other readily accessible means, |
||||
then you must either (1) cause the Corresponding Source to be so |
||||
available, or (2) arrange to deprive yourself of the benefit of the |
||||
patent license for this particular work, or (3) arrange, in a manner |
||||
consistent with the requirements of this License, to extend the patent |
||||
license to downstream recipients. "Knowingly relying" means you have |
||||
actual knowledge that, but for the patent license, your conveying the |
||||
covered work in a country, or your recipient's use of the covered work |
||||
in a country, would infringe one or more identifiable patents in that |
||||
country that you have reason to believe are valid. |
||||
|
||||
If, pursuant to or in connection with a single transaction or |
||||
arrangement, you convey, or propagate by procuring conveyance of, a |
||||
covered work, and grant a patent license to some of the parties |
||||
receiving the covered work authorizing them to use, propagate, modify |
||||
or convey a specific copy of the covered work, then the patent license |
||||
you grant is automatically extended to all recipients of the covered |
||||
work and works based on it. |
||||
|
||||
A patent license is "discriminatory" if it does not include within |
||||
the scope of its coverage, prohibits the exercise of, or is |
||||
conditioned on the non-exercise of one or more of the rights that are |
||||
specifically granted under this License. You may not convey a covered |
||||
work if you are a party to an arrangement with a third party that is |
||||
in the business of distributing software, under which you make payment |
||||
to the third party based on the extent of your activity of conveying |
||||
the work, and under which the third party grants, to any of the |
||||
parties who would receive the covered work from you, a discriminatory |
||||
patent license (a) in connection with copies of the covered work |
||||
conveyed by you (or copies made from those copies), or (b) primarily |
||||
for and in connection with specific products or compilations that |
||||
contain the covered work, unless you entered into that arrangement, |
||||
or that patent license was granted, prior to 28 March 2007. |
||||
|
||||
Nothing in this License shall be construed as excluding or limiting |
||||
any implied license or other defenses to infringement that may |
||||
otherwise be available to you under applicable patent law. |
||||
|
||||
12. No Surrender of Others' Freedom. |
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or |
||||
otherwise) that contradict the conditions of this License, they do not |
||||
excuse you from the conditions of this License. If you cannot convey a |
||||
covered work so as to satisfy simultaneously your obligations under this |
||||
License and any other pertinent obligations, then as a consequence you may |
||||
not convey it at all. For example, if you agree to terms that obligate you |
||||
to collect a royalty for further conveying from those to whom you convey |
||||
the Program, the only way you could satisfy both those terms and this |
||||
License would be to refrain entirely from conveying the Program. |
||||
|
||||
13. Use with the GNU Affero General Public License. |
||||
|
||||
Notwithstanding any other provision of this License, you have |
||||
permission to link or combine any covered work with a work licensed |
||||
under version 3 of the GNU Affero General Public License into a single |
||||
combined work, and to convey the resulting work. The terms of this |
||||
License will continue to apply to the part which is the covered work, |
||||
but the special requirements of the GNU Affero General Public License, |
||||
section 13, concerning interaction through a network will apply to the |
||||
combination as such. |
||||
|
||||
14. Revised Versions of this License. |
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of |
||||
the GNU General Public License from time to time. Such new versions will |
||||
be similar in spirit to the present version, but may differ in detail to |
||||
address new problems or concerns. |
||||
|
||||
Each version is given a distinguishing version number. If the |
||||
Program specifies that a certain numbered version of the GNU General |
||||
Public License "or any later version" applies to it, you have the |
||||
option of following the terms and conditions either of that numbered |
||||
version or of any later version published by the Free Software |
||||
Foundation. If the Program does not specify a version number of the |
||||
GNU General Public License, you may choose any version ever published |
||||
by the Free Software Foundation. |
||||
|
||||
If the Program specifies that a proxy can decide which future |
||||
versions of the GNU General Public License can be used, that proxy's |
||||
public statement of acceptance of a version permanently authorizes you |
||||
to choose that version for the Program. |
||||
|
||||
Later license versions may give you additional or different |
||||
permissions. However, no additional obligations are imposed on any |
||||
author or copyright holder as a result of your choosing to follow a |
||||
later version. |
||||
|
||||
15. Disclaimer of Warranty. |
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
||||
|
||||
16. Limitation of Liability. |
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGES. |
||||
|
||||
17. Interpretation of Sections 15 and 16. |
||||
|
||||
If the disclaimer of warranty and limitation of liability provided |
||||
above cannot be given local legal effect according to their terms, |
||||
reviewing courts shall apply local law that most closely approximates |
||||
an absolute waiver of all civil liability in connection with the |
||||
Program, unless a warranty or assumption of liability accompanies a |
||||
copy of the Program in return for a fee. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
How to Apply These Terms to Your New Programs |
||||
|
||||
If you develop a new program, and you want it to be of the greatest |
||||
possible use to the public, the best way to achieve this is to make it |
||||
free software which everyone can redistribute and change under these terms. |
||||
|
||||
To do so, attach the following notices to the program. It is safest |
||||
to attach them to the start of each source file to most effectively |
||||
state the exclusion of warranty; and each file should have at least |
||||
the "copyright" line and a pointer to where the full notice is found. |
||||
|
||||
<one line to give the program's name and a brief idea of what it does.> |
||||
Copyright (C) <year> <name of author> |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
Also add information on how to contact you by electronic and paper mail. |
||||
|
||||
If the program does terminal interaction, make it output a short |
||||
notice like this when it starts in an interactive mode: |
||||
|
||||
<program> Copyright (C) <year> <name of author> |
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
||||
This is free software, and you are welcome to redistribute it |
||||
under certain conditions; type `show c' for details. |
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate |
||||
parts of the General Public License. Of course, your program's commands |
||||
might be different; for a GUI interface, you would use an "about box". |
||||
|
||||
You should also get your employer (if you work as a programmer) or school, |
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. |
||||
For more information on this, and how to apply and follow the GNU GPL, see |
||||
<http://www.gnu.org/licenses/>. |
||||
|
||||
The GNU General Public License does not permit incorporating your program |
||||
into proprietary programs. If your program is a subroutine library, you |
||||
may consider it more useful to permit linking proprietary applications with |
||||
the library. If this is what you want to do, use the GNU Lesser General |
||||
Public License instead of this License. But first, please read |
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>. |
@ -0,0 +1,374 @@
|
||||
<?php |
||||
|
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* This class inspired by Chris Jean's work, here: |
||||
* http://chrisjean.com/2009/02/14/generating-mime-type-in-php-is-not-magic/ |
||||
* |
||||
* It does some MIME trickery, inspired by the need to to deal with Openoffice |
||||
* and MS Office 2007 file formats -- which are often mis-interpreted by |
||||
* mime-magic, fileinfo, and the *nix `file` command. |
||||
* |
||||
* In Drupal 6, we also make use of file_get_mimetype. See: |
||||
* http://api.drupal.org/api/function/file_get_mimetype/6 |
||||
* ... however this only provides a uni-directional lookup (ext->mime). |
||||
* While I don't have a specific use case for a mime->extension lookup, I think |
||||
* it's good to have in here. |
||||
* |
||||
* Drupal 7 will have better mime handlers. See: |
||||
* http://api.drupal.org/api/function/file_default_mimetype_mapping/7 |
||||
* |
||||
*/ |
||||
|
||||
class MimeClass { |
||||
|
||||
private $private_mime_types = array( |
||||
/* |
||||
* This is a shortlist of mimetypes which should catch most |
||||
* mimetype<-->extension lookups in the context of Islandora collections. |
||||
* |
||||
* It has been cut from a much longer list. |
||||
* |
||||
* Two types of mimetypes should be put in this list: |
||||
* 1) Special emerging formats which may not yet be expressed in the system |
||||
* mime.types file. |
||||
* 2) Heavily used mimetypes of particular importance to the Islandora |
||||
* project, as lookups against this list will be quicker and less |
||||
* resource intensive than other methods. |
||||
* |
||||
* Lookups are first checked against this short list. |
||||
* If no results are found, then the lookup function may move |
||||
* on to check other sources, namely the system's mime.types file. |
||||
* |
||||
* In most cases though, this short list should suffice. |
||||
* |
||||
* If modifying this list, please note that for promiscuous mimetypes |
||||
* (those which map to multiple extensions, such as text/plain) |
||||
* The function get_extension will always return the *LAST* extension |
||||
* in this list, so you should put your preferred extension *LAST*. |
||||
* |
||||
* e.g... |
||||
* "jpeg" => "image/jpeg", |
||||
* "jpe" => "image/jpeg", |
||||
* "jpg" => "image/jpeg", |
||||
* |
||||
* $this->get_extension('image/jpeg') will always return 'jpg'. |
||||
* |
||||
*/ |
||||
// openoffice: |
||||
'odb' => 'application/vnd.oasis.opendocument.database', |
||||
'odc' => 'application/vnd.oasis.opendocument.chart', |
||||
'odf' => 'application/vnd.oasis.opendocument.formula', |
||||
'odg' => 'application/vnd.oasis.opendocument.graphics', |
||||
'odi' => 'application/vnd.oasis.opendocument.image', |
||||
'odm' => 'application/vnd.oasis.opendocument.text-master', |
||||
'odp' => 'application/vnd.oasis.opendocument.presentation', |
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet', |
||||
'odt' => 'application/vnd.oasis.opendocument.text', |
||||
'otg' => 'application/vnd.oasis.opendocument.graphics-template', |
||||
'oth' => 'application/vnd.oasis.opendocument.text-web', |
||||
'otp' => 'application/vnd.oasis.opendocument.presentation-template', |
||||
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', |
||||
'ott' => 'application/vnd.oasis.opendocument.text-template', |
||||
// staroffice: |
||||
'stc' => 'application/vnd.sun.xml.calc.template', |
||||
'std' => 'application/vnd.sun.xml.draw.template', |
||||
'sti' => 'application/vnd.sun.xml.impress.template', |
||||
'stw' => 'application/vnd.sun.xml.writer.template', |
||||
'sxc' => 'application/vnd.sun.xml.calc', |
||||
'sxd' => 'application/vnd.sun.xml.draw', |
||||
'sxg' => 'application/vnd.sun.xml.writer.global', |
||||
'sxi' => 'application/vnd.sun.xml.impress', |
||||
'sxm' => 'application/vnd.sun.xml.math', |
||||
'sxw' => 'application/vnd.sun.xml.writer', |
||||
// k-office: |
||||
'kil' => 'application/x-killustrator', |
||||
'kpt' => 'application/x-kpresenter', |
||||
'kpr' => 'application/x-kpresenter', |
||||
'ksp' => 'application/x-kspread', |
||||
'kwt' => 'application/x-kword', |
||||
'kwd' => 'application/x-kword', |
||||
// MS office 97: |
||||
'doc' => 'application/msword', |
||||
'xls' => 'application/vnd.ms-excel', |
||||
'ppt' => 'application/vnd.ms-powerpoint', |
||||
// office2007: |
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
||||
'docm' => 'application/vnd.ms-word.document.macroEnabled.12', |
||||
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', |
||||
'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', |
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', |
||||
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', |
||||
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', |
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', |
||||
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', |
||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', |
||||
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', |
||||
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', |
||||
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', |
||||
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', |
||||
'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', |
||||
'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', |
||||
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', |
||||
'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', |
||||
// Wordperfect (who cares?): |
||||
'wpd' => 'application/wordperfect', |
||||
// Common and generic containers: |
||||
'pdf' => 'application/pdf', |
||||
'eps' => 'application/postscript', |
||||
'ps' => 'application/postscript', |
||||
'rtf' => 'text/rtf', |
||||
'rtx' => 'text/richtext', |
||||
'latex' => 'application/x-latex', |
||||
'tex' => 'application/x-tex', |
||||
'texi' => 'application/x-texinfo', |
||||
'texinfo' => 'application/x-texinfo', |
||||
// *ml: |
||||
'css' => 'text/css', |
||||
'htm' => 'text/html', |
||||
'html' => 'text/html', |
||||
'wbxml' => 'application/vnd.wap.wbxml', |
||||
'xht' => 'application/xhtml+xml', |
||||
'xhtml' => 'application/xhtml+xml', |
||||
'xsl' => 'text/xml', |
||||
'xslt' => 'text/xml', |
||||
'xml' => 'text/xml', |
||||
'csv' => 'text/csv', |
||||
'tsv' => 'text/tab-separated-values', |
||||
'txt' => 'text/plain', |
||||
// images: |
||||
"bmp" => "image/bmp", |
||||
"gif" => "image/gif", |
||||
"ief" => "image/ief", |
||||
"jpeg" => "image/jpeg", |
||||
"jpe" => "image/jpeg", |
||||
"jpg" => "image/jpeg", |
||||
"jp2" => "image/jp2", |
||||
"png" => "image/png", |
||||
"tiff" => "image/tiff", |
||||
"tif" => "image/tif", |
||||
"djvu" => "image/vnd.djvu", |
||||
"djv" => "image/vnd.djvu", |
||||
"wbmp" => "image/vnd.wap.wbmp", |
||||
"ras" => "image/x-cmu-raster", |
||||
"pnm" => "image/x-portable-anymap", |
||||
"pbm" => "image/x-portable-bitmap", |
||||
"pgm" => "image/x-portable-graymap", |
||||
"ppm" => "image/x-portable-pixmap", |
||||
"rgb" => "image/x-rgb", |
||||
"xbm" => "image/x-xbitmap", |
||||
"xpm" => "image/x-xpixmap", |
||||
"xwd" => "image/x-windowdump", |
||||
// videos: |
||||
"mpeg" => "video/mpeg", |
||||
"mpe" => "video/mpeg", |
||||
"mpg" => "video/mpeg", |
||||
"m4v" => "video/mp4", |
||||
"mp4" => "video/mp4", |
||||
"ogv" => "video/ogg", |
||||
"qt" => "video/quicktime", |
||||
"mov" => "video/quicktime", |
||||
"mxu" => "video/vnd.mpegurl", |
||||
"avi" => "video/x-msvideo", |
||||
"movie" => "video/x-sgi-movie", |
||||
"flv" => "video/x-flv", |
||||
"swf" => "application/x-shockwave-flash", |
||||
'mkv' => "video/x-matroska", |
||||
'wmv' => 'video/x-ms-wmv', |
||||
// audio: |
||||
"mp3" => "audio/mpeg", |
||||
"mp4a" => "audio/mp4", |
||||
"m4a" => "audio/mp4", |
||||
"oga" => "audio/ogg", |
||||
"ogg" => "audio/ogg", |
||||
"flac" => "audio/x-flac", |
||||
"wav" => "audio/vnd.wave", |
||||
/* Compressed formats: |
||||
(note: http://svn.cleancode.org/svn/email/trunk/mime.types).*/ |
||||
"tgz" => "application/x-gzip", |
||||
"gz" => "application/x-gzip", |
||||
"tar" => "application/x-tar", |
||||
"gtar" => "application/x-gtar", |
||||
"zip" => "application/x-zip", |
||||
// others: |
||||
'bin' => 'application/octet-stream', |
||||
'json' => 'application/json', |
||||
); |
||||
|
||||
private $private_file_extensions; |
||||
private $system_types; |
||||
private $system_exts; |
||||
private $etc_mime_types = '/etc/mime.types'; |
||||
|
||||
/** |
||||
* Construtor |
||||
*/ |
||||
public function __construct() { |
||||
|
||||
// Populate the reverse shortlist: |
||||
$this->private_file_extensions = array_flip($this->private_mime_types); |
||||
|
||||
// Pick up a local mime.types file if it is available. |
||||
if (is_readable('mime.types')) { |
||||
$this->etc_mime_types = 'mime.types'; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* function: getType |
||||
* description: An alias to get_mimetype, |
||||
* for backwards-compatibility with our old mimetype class. |
||||
* |
||||
* @param type $filename |
||||
* @return type |
||||
*/ |
||||
public function getType($filename) { |
||||
return $this->get_mimetype($filename); |
||||
} |
||||
|
||||
/** |
||||
* function: get_mimetype |
||||
* description: returns a mimetype associated with the |
||||
* file extension of $filename |
||||
* |
||||
* @param type $filename |
||||
* @param type $debug |
||||
* @return string |
||||
* mimetype associated with the file extension of $filename |
||||
*/ |
||||
public function get_mimetype($filename, $debug = FALSE) { |
||||
$ext = strtolower(substr($filename, strrpos($filename, '.') + 1)); |
||||
|
||||
if (!empty($this->private_mime_types[$ext])) { |
||||
if (TRUE === $debug) { |
||||
return array('mime_type' => $this->private_mime_types[$ext], 'method' => 'from_array'); |
||||
} |
||||
return $this->private_mime_types[$ext]; |
||||
} |
||||
|
||||
if (function_exists('file_get_mimetype')) { |
||||
$drupal_mimetype = file_get_mimetype($filename); |
||||
if ('application/octet-stream' != $drupal_mimetype) { |
||||
if (TRUE == $debug) { |
||||
return array('mime_type' => $drupal_mimetype, 'method' => 'file_get_mimetype'); |
||||
} |
||||
return $drupal_mimetype; |
||||
} |
||||
} |
||||
|
||||
if (!isset($this->system_types)) { |
||||
$this->system_types = $this->system_extension_mime_types(); |
||||
} |
||||
if (isset($this->system_types[$ext])) { |
||||
if (TRUE == $debug) { |
||||
return array('mime_type' => $this->system_types[$ext], 'method' => 'mime.types'); |
||||
} |
||||
return $this->system_types[$ext]; |
||||
} |
||||
|
||||
if (TRUE === $debug) { |
||||
return array('mime_type' => 'application/octet-stream', 'method' => 'last_resort'); |
||||
} |
||||
return 'application/octet-stream'; |
||||
} |
||||
|
||||
/** |
||||
* function: get_extension |
||||
* description: returns *one* valid file extension for a given $mime_type |
||||
* |
||||
* @param type $mime_type |
||||
* @param type $debug |
||||
* @return type |
||||
*/ |
||||
public function get_extension($mime_type, $debug = FALSE) { |
||||
|
||||
if (!empty($this->private_file_extensions[$mime_type])) { |
||||
if (TRUE == $debug) { |
||||
return array('extension' => $this->private_file_extensions[$mime_type], 'method' => 'from_array'); |
||||
} |
||||
return $this->private_file_extensions[$mime_type]; |
||||
} |
||||
|
||||
if (!isset($this->system_exts)) { |
||||
$this->system_exts = $this->system_mime_type_extensions(); |
||||
} |
||||
if (isset($this->system_exts[$mime_type])) { |
||||
if (TRUE == $debug) { |
||||
return array('extension' => $this->system_exts[$mime_type], 'method' => 'mime.types'); |
||||
} |
||||
return $this->system_exts[$mime_type]; |
||||
} |
||||
|
||||
if (TRUE == $debug) { |
||||
return array('extension' => 'bin', 'method' => 'last_resort'); |
||||
} |
||||
return 'bin'; |
||||
} |
||||
|
||||
/** |
||||
* function: system_mime_type_extensions |
||||
* description: populates an internal array of mimetype/extension associations |
||||
* from the system mime.types file, or a local mime.types if one is found (see |
||||
* __constuctor). |
||||
* return: array of mimetype => extension |
||||
*/ |
||||
private function system_mime_type_extensions() { |
||||
$out = array(); |
||||
if (file_exists($this->etc_mime_types)) { |
||||
$file = fopen($this->etc_mime_types, 'r'); |
||||
while (($line = fgets($file)) !== FALSE) { |
||||
$line = trim(preg_replace('/#.*/', '', $line)); |
||||
if (!$line) { |
||||
continue; |
||||
} |
||||
$parts = preg_split('/\s+/', $line); |
||||
if (count($parts) == 1) { |
||||
continue; |
||||
} |
||||
// A single part means a mimetype without extensions, which we ignore. |
||||
$type = array_shift($parts); |
||||
if (!isset($out[$type])) { |
||||
$out[$type] = array_shift($parts); |
||||
} |
||||
// We take the first ext from the line if many are present. |
||||
} |
||||
fclose($file); |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* function: system_mime_type_extensions |
||||
* description: populates an internal array of mimetype/extension associations |
||||
* from the system mime.types file, or a local mime.types if one is found (see |
||||
* __constuctor). |
||||
* return: array of extension => mimetype |
||||
*/ |
||||
private function system_extension_mime_types() { |
||||
$out = array(); |
||||
if (file_exists($this->etc_mime_types)) { |
||||
$file = fopen($this->etc_mime_types, 'r'); |
||||
while (($line = fgets($file)) !== FALSE) { |
||||
$line = trim(preg_replace('/#.*/', '', $line)); |
||||
if (!$line) { |
||||
continue; |
||||
} |
||||
$parts = preg_split('/\s+/', $line); |
||||
if (count($parts) == 1) { |
||||
continue; |
||||
} |
||||
// A single part means a mimetype without extensions, which we ignore. |
||||
$type = array_shift($parts); |
||||
foreach ($parts as $part) { |
||||
$out[$part] = $type; |
||||
} |
||||
} |
||||
fclose($file); |
||||
} |
||||
return $out; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,303 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file ObjectDetails.inc |
||||
* The functions required to define and respond to all the default object |
||||
* details display modes. |
||||
*/ |
||||
|
||||
/** |
||||
* Islandora core object details display modes. These are the default display |
||||
* modes that are always available. |
||||
* @return A list of display modes that can be used to render the object details |
||||
* page. |
||||
*/ |
||||
function fedora_repository_islandora_object_details_display() { |
||||
$profiles = array( |
||||
'hidden' => array( |
||||
"name" => "Hidden", |
||||
"module" => "fedora_repository", |
||||
"file" => "ObjectDetails.inc", |
||||
"function" => "fedora_repository_object_details_hidden", |
||||
"description" => t("No object details page"), |
||||
), |
||||
'xslt' => array( |
||||
"name" => "XSLT", |
||||
"module" => "fedora_repository", |
||||
"file" => "ObjectDetails.inc", |
||||
"function" => "fedora_repository_object_details_xslt", |
||||
"description" => t("Show a datastream with an XSLT"), |
||||
"config" => "admin/settings/fedora_repository/object_details_xslt", |
||||
), |
||||
'table' => array( |
||||
"name" => "Table", |
||||
"module" => "fedora_repository", |
||||
"file" => "ObjectDetails.inc", |
||||
"function" => "fedora_repository_object_details_table", |
||||
"description" => t("Show a datastream with a table"), |
||||
"config" => "admin/settings/fedora_repository/object_details_table", |
||||
) |
||||
); |
||||
return $profiles; |
||||
} |
||||
|
||||
/** |
||||
* The renderer for the "hidden" display mode. In this mode, no data is |
||||
* displayed. This is supplied so you can disable the object details metadata |
||||
* display without disabling the tab entirely. |
||||
* @param item The item with the metadata to display. |
||||
* @return The fully composed object details metadata display. |
||||
*/ |
||||
function fedora_repository_object_details_hidden($item) { |
||||
// do nothing |
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* The renderer for the "xslt" display mode. In this mode, an xslt is applied |
||||
* to the selected datastream to produce a user defined look and feel to the |
||||
* output data. |
||||
* @param item The item with the metadata to display. |
||||
* @return The fully composed object details metadata display. |
||||
*/ |
||||
function fedora_repository_object_details_XSLT($item) { |
||||
global $base_url; |
||||
$path = drupal_get_path('module', 'fedora_repository'); |
||||
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); |
||||
|
||||
$dsid = variable_get('islandora_object_details_xslt_datastream', 'DC'); |
||||
// special case for DC+QDC for backward compatibility |
||||
if ($dsid == 'DC' || $dsid == 'QDC') { |
||||
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; |
||||
} |
||||
$xmlstr = $item->get_datastream_dissemination($dsid); |
||||
|
||||
$default_to_dc = FALSE; |
||||
if (empty($xmlstr) && variable_get('islandora_object_details_xslt_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') { |
||||
$xmlstr = $item->get_datastream_dissemination('DC'); |
||||
$default_to_dc = TRUE; |
||||
} |
||||
if (empty($xmlstr)) { |
||||
return t('Error - could not find datastream @dsid on object @pid<br/>Please contact the site administrator.', |
||||
array('@dsid' => $dsid, '@pid' => $item->pid)); |
||||
} |
||||
|
||||
try { |
||||
$proc = new XsltProcessor(); |
||||
} catch (Exception $e) { |
||||
watchdog('fedora_repository', "Error while creating XSLT processor: @e", array('@e' => $e->getMessage()), WATCHDOG_ERROR); |
||||
return; |
||||
} |
||||
|
||||
$proc->setParameter('', 'baseUrl', $base_url); |
||||
$proc->setParameter('', 'path', $path); |
||||
$input = NULL; |
||||
|
||||
if (!$default_to_dc) { |
||||
$xsl_file = variable_get('islandora_object_details_xslt_sheet', 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl'); |
||||
} |
||||
else { |
||||
$xsl_file = 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl'; |
||||
} |
||||
|
||||
// set an error message in case xslt parsing fails |
||||
$output = t("Failed to parse xslt file at @xsltFile", array('@xsltFile' => $xsl_file)); |
||||
if (is_readable($xsl_file)) { |
||||
$xsl = new DomDocument(); |
||||
$input = new DomDocument(); |
||||
try { |
||||
$xsl->load($xsl_file); |
||||
|
||||
$input->loadXML(trim($xmlstr)); |
||||
} catch (Exception $e) { |
||||
watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR); |
||||
} |
||||
$xsl = $proc->importStylesheet($xsl); |
||||
$newdom = $proc->transformToDoc($input); |
||||
$output = $newdom->saveHTML(); |
||||
} |
||||
return $output; |
||||
} |
||||
|
||||
/** |
||||
* The renderer for the "table" display mode. In this mode, the requested |
||||
* datastream is rendered using a simple table with keys(tags) on the left and |
||||
* values on the right. |
||||
* @param item The item with the metadata to display. |
||||
* @return The fully composed object details metadata display. |
||||
*/ |
||||
function fedora_repository_object_details_table($item) { |
||||
global $base_url; |
||||
$path = drupal_get_path('module', 'fedora_repository'); |
||||
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); |
||||
|
||||
$dsid = variable_get('islandora_object_details_table_datastream', 'DC'); |
||||
// special case for DC+QDC for backward compatibility |
||||
if ($dsid == 'DC' || $dsid == 'QDC') { |
||||
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; |
||||
} |
||||
$xmlstr = $item->get_datastream_dissemination($dsid); |
||||
|
||||
if (empty($xmlstr) && variable_get('islandora_object_details_table_default_dc', FALSE) && $dsid != 'DC' && $dsid != 'QDC') { |
||||
$dsid = 'DC'; |
||||
$xmlstr = $item->get_datastream_dissemination($dsid); |
||||
} |
||||
if (empty($xmlstr)) { |
||||
return t('Error - could not find datastream @dsid on object @pid<br/>Please contact the site administrator.', |
||||
array('@dsid' => $dsid, '@pid' => $item->pid)); |
||||
} |
||||
|
||||
$simplexml = new SimpleXMLElement($xmlstr); |
||||
|
||||
$headers = array( |
||||
array( |
||||
'data' => t('Metadata (@dsid)', array('@dsid' => $dsid)), |
||||
'colspan' => 2, |
||||
), |
||||
); |
||||
$rows = array(); |
||||
foreach ($simplexml->getNamespaces(TRUE) as $ns) { |
||||
foreach ($simplexml->children($ns) as $child) { |
||||
$rows[] = array( |
||||
array( |
||||
'data' => $child->getName(), |
||||
'class' => 'dc-tag-name', |
||||
), |
||||
array( |
||||
'data' => (string)$child, |
||||
'class' => 'dc-content', |
||||
), |
||||
); |
||||
} |
||||
} |
||||
|
||||
return theme('table', $headers, $rows, array('class' => 'dc-table')); |
||||
} |
||||
|
||||
/** |
||||
* Configuration page for the xslt display mode. |
||||
* |
||||
* This mode requires two parameters: the datastream to render, and the xslt to |
||||
* apply to it. |
||||
* |
||||
* @return |
||||
* The configuration page. |
||||
*/ |
||||
function fedora_repository_object_details_XSLT_config() { |
||||
$form = array(); |
||||
$form['config'] = array( |
||||
'#type' => 'fieldset', |
||||
'#title' => t("XSLT display options"), |
||||
); |
||||
|
||||
$options = module_invoke_all("object_details_get_available_xslts"); |
||||
|
||||
$form['config']['xslt'] = array( |
||||
'#type' => 'select', |
||||
'#title' => t("XSL transform to use"), |
||||
'#default_value' => variable_get('islandora_object_details_xslt_sheet', 'sites/all/modules/islandora/object_details_xslts/convertQDC.xsl'), |
||||
'#options' => $options, |
||||
'#key_type' => 'associative', |
||||
'#required' => TRUE, |
||||
); |
||||
$form['config']['dsid'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t("Datastream to transform"), |
||||
'#default_value' => variable_get('islandora_object_details_xslt_datastream', 'DC'), |
||||
'#required' => TRUE, |
||||
); |
||||
$form['config']['default_dc'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t("If the datastream to transform is unavailable, attempt to transform using the DC datastream"), |
||||
'#default_value' => variable_get('islandora_object_details_xslt_default_dc', FALSE), |
||||
); |
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t("Submit"), |
||||
'#weight' => 1, |
||||
); |
||||
|
||||
return $form; |
||||
} |
||||
/** |
||||
* Custom submit handler for the xslt configuration page. |
||||
* |
||||
* @param $form |
||||
* @param &$form_state |
||||
* The user supplied values for the form. |
||||
*/ |
||||
function fedora_repository_object_details_XSLT_config_submit($form, &$form_state) { |
||||
variable_set('islandora_object_details_display_table', 'xslt'); |
||||
variable_set('islandora_object_details_xslt_sheet', $form_state['values']['xslt']); |
||||
variable_set('islandora_object_details_xslt_datastream', $form_state['values']['dsid']); |
||||
variable_set('islandora_object_details_xslt_default_dc', $form_state['values']['default_dc']); |
||||
drupal_set_message('Object Details view has been set to XSLT and your configuration has been saved'); |
||||
} |
||||
|
||||
/** |
||||
* Base function to supply the available xslt files. |
||||
* |
||||
* Modules implementing this hook need to return an array describing where the |
||||
* XSLT is. The array key is the path to the XSLT (paths start with sites/) and |
||||
* the value in the array is the display name. In the simplest form you can use |
||||
* file_scan_directory like we do here - this puts the filename as the display |
||||
* name and will automatically detect new files as they are added. |
||||
*/ |
||||
function fedora_repository_object_details_get_available_xslts() { |
||||
$folder = drupal_get_path("module", "fedora_repository") ."/object_details_xslts/"; |
||||
// retrieve the filenames from the system |
||||
$xslts = file_scan_directory($folder, ".xsl"); |
||||
$options = array(); |
||||
foreach ($xslts as $xsl) { |
||||
$options[$xsl->filename] = $xsl->basename; |
||||
} |
||||
return $options; |
||||
} |
||||
|
||||
/** |
||||
* Configuration page for the table display mode. This mode requires only one |
||||
* parameter: the datastream to render. |
||||
* |
||||
* @return |
||||
* The configuration page. |
||||
*/ |
||||
function fedora_repository_object_details_table_config() { |
||||
$form = array(); |
||||
$form['config'] = array( |
||||
'#type' => 'fieldset', |
||||
'#title' => t("Table display options"), |
||||
); |
||||
|
||||
$form['config']['dsid'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t("Datastream to transform"), |
||||
'#default_value' => variable_get('islandora_object_details_table_datastream', 'DC'), |
||||
'#required' => TRUE, |
||||
); |
||||
$form['config']['default_dc'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t("If the datastream to transform is unavailable, attempt to transform using the DC datastream"), |
||||
'#default_value' => variable_get('islandora_object_details_table_default_dc', FALSE), |
||||
); |
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t("Submit"), |
||||
'#weight' => 1, |
||||
); |
||||
|
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Custom submit handler for the table configuration page. |
||||
* |
||||
* @param $form |
||||
* @param &$form_state |
||||
* The user supplied values for the form. |
||||
*/ |
||||
function fedora_repository_object_details_table_config_submit($form, &$form_state) { |
||||
variable_set('islandora_object_details_display_table', 'table'); |
||||
variable_set('islandora_object_details_table_datastream', $form_state['values']['dsid']); |
||||
variable_set('islandora_object_details_table_default_dc', $form_state['values']['default_dc']); |
||||
drupal_set_message('Object Details view has been set to Table and your configuration has been saved'); |
||||
} |
@ -0,0 +1,62 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* Setups the globals for the Drupal pager. |
||||
* |
||||
* Does just what it says: Hacks the default Drupal pager such that it might |
||||
* be rendered, likely with: theme('pager', array(), $per_page, $pager_name) |
||||
* (I reccomend seeing the real documentation for more detail, but the first |
||||
* array can be a list of the tags to use for first, previous, next and last |
||||
* (text in the pager), I don't believe per_page is actually used in the theme |
||||
* function, and $pager_name is an integer used to identify the pager (such |
||||
* that there can be more than one--that is, tracking different lists of |
||||
* content on a single page. You can render the exact same pager multiple |
||||
* times, say if you want one at the top and bottom of a list, using the same |
||||
* ID/pager_name. |
||||
* |
||||
* @global $pager_total array |
||||
* Numerically indexed array, where keys are the $pager_names and values |
||||
* are the number of pages in the given set, based on: ceil($total_items/$per_page); |
||||
* @global $pager_page_array array |
||||
* Numerically indexed array, where keys are the $pager_names and values |
||||
* are the page selected in the relevant set. |
||||
* @param $pager_name int |
||||
* An integer to identify the pager to affect. Do note that paging in using |
||||
* this function will add the 'page' HTTP GET parameter to the URL, with |
||||
* the value containing a comma-separated list with max($pager_name + 1) |
||||
* values--that is, if you create a single pager named '10', the 'next' |
||||
* link will look something like: 0,0,0,0,0,0,0,0,0,0,1 |
||||
* @param $per_page int |
||||
* An integer representing the number of items per page. |
||||
* @param $total_items int |
||||
* An integer representing the total number of items in the set. |
||||
* @return int |
||||
* An integer representing what the current page should be. |
||||
*/ |
||||
function fedora_repository_setup_pager($pager_name, $per_page = NULL, $total_items = NULL) { |
||||
global $pager_total, $pager_page_array; |
||||
|
||||
if ($per_page !== NULL && $total_items !== NULL) { |
||||
$pager_total[$pager_name] = ceil($total_items / $per_page); |
||||
} |
||||
|
||||
//XXX: Don't know that this is neccessary, to try to load all the time, or |
||||
// whether Drupal will load it automatically somewhere... Docs seems a |
||||
// a little sparse. |
||||
$page_info = explode(',', isset($_GET['page']) ? $_GET['page'] : ''); |
||||
$page = $page_info[$pager_name]; |
||||
if ($page < 0) { |
||||
$page = 0; |
||||
} |
||||
|
||||
if (!isset($pager_page_array)) { |
||||
$pager_page_array = pager_load_array($page, $pager_name, $page_info); |
||||
} |
||||
else { |
||||
$pager_page_array = pager_load_array($page, $pager_name, $pager_page_array); |
||||
} |
||||
|
||||
$page = $pager_page_array[$pager_name]; |
||||
return $page; |
||||
} |
||||
|
@ -0,0 +1,16 @@
|
||||
Islandora Fedora Repository Module |
||||
|
||||
For installation and customization instructions please see the documentation and the DuraSpace Wiki: |
||||
|
||||
https://wiki.duraspace.org/display/ISLANDORA/Islandora |
||||
|
||||
All bugs, feature requests and improvement suggestions are tracked at the DuraSpace JIRA: |
||||
|
||||
https://jira.duraspace.org/browse/ISLANDORA |
||||
|
||||
Fedora/Drupal Security |
||||
====================== |
||||
The islandora_drupal_filter passes the username of 'anonymous' through to Fedora for unauthenticated |
||||
Drupal Users. A user with the name of 'anonymous' may have XACML policies applied to them that are |
||||
meant to be applied to Drupal users that are not logged in or vice-versa. This is a potential security |
||||
issue that can be plugged by creating a user named 'anonymous' and restricting access to the account. |
@ -1,121 +0,0 @@
|
||||
# Islandora |
||||
|
||||
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg?style=flat-square)](https://php.net/) |
||||
[![Build Status](https://github.com/islandora/islandora/actions/workflows/build-2.x.yml/badge.svg)](https://github.com/Islandora/islandora/actions) |
||||
[![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) |
||||
[![LICENSE](https://img.shields.io/badge/license-GPLv2-blue.svg?style=flat-square)](./LICENSE) |
||||
[![codecov](https://codecov.io/gh/Islandora/islandora/branch/2.x/graph/badge.svg)](https://codecov.io/gh/Islandora/islandora) |
||||
|
||||
## Introduction |
||||
|
||||
This is the core module of Islandora's digital repository ecosystem. The `islandora` module provides: |
||||
- Fedora 5 integration via the [flysystem](https://drupal.org/project/flysystem) module |
||||
- Integration with the [context](https://drupal.org/project/context) module to control your digital repository's behaviour |
||||
- Publishing messages to a queue so they can be processed in the background |
||||
|
||||
`islandora` contains several submodules and features: |
||||
- `islandora_core_feature` (**required**) |
||||
- Configuration required by the `islandora` module |
||||
- `islandora_image` |
||||
- Integrates with a [Houdini](https://github.com/Islandora/Crayfish/tree/dev/Houdini) (Imagemagick) server for image processing |
||||
- `islandora_audio` and `islandora_video` |
||||
- Integrate with a [Homarus](https://github.com/Islandora/Crayfish/tree/dev/Homarus) (`ffmpeg`) server for audio/video processing |
||||
- `islandora_text_extraction` and `islandora_text_extraction_defaults` |
||||
- Integrate with a [Hypercube](https://github.com/Islandora/Crayfish/tree/dev/Hypercube) (`tessseract` and `pdftotext`) server for text extraction |
||||
- `islandora_breadcrumbs` |
||||
- Provides breadcrumbs following collection structure |
||||
- `islandora_iiif` |
||||
- Provides IIIF manifests for repository content |
||||
|
||||
## Requirements |
||||
|
||||
Installing via composer will download all required libraries and modules. However, for reference, `islandora` requires the following drupal modules: |
||||
|
||||
- [context](http://drupal.org/project/context) |
||||
- [search_api](http://drupal.org/project/search_api) |
||||
- [jsonld](http://drupal.org/project/jsonld) |
||||
- [jwt](http://drupal.org/project/jwt) |
||||
- [filehash](http://drupal.org/project/filehash) |
||||
- [prepopulate](http://drupal.org/project/prepopulate) |
||||
- [eva](http://drupal.org/project/eva) |
||||
- [features](http://drupal.org/project/features) |
||||
- [migrate_plus](http://drupal.org/project/migrate_plus) |
||||
- [migrate_source_csv](http://drupal.org/project/migrate_source_csv) |
||||
- [flysystem](http://drupal.org/project/flysystem) |
||||
|
||||
It also requires the following PHP libraries: |
||||
|
||||
- [Crayfish Commons](https://packagist.org/packages/islandora/crayfish-commons) |
||||
- [Stomp PHP](http://drupal.org/project/) |
||||
|
||||
If you are using a Drush version less than 10.4 you will also need to install and enable [migrate_tools](http://drupal.org/project/migrate_tools) separately. |
||||
|
||||
## Installation |
||||
|
||||
For a full digital repository solution, see our [installation documentation](https://islandora.github.io/documentation/installation/component_overview/). |
||||
|
||||
To download/enable just this module, use the following from the command line: |
||||
|
||||
```bash |
||||
$ composer require islandora/islandora |
||||
$ drush en islandora_core_feature |
||||
$ drush mim islandora_tags |
||||
``` |
||||
|
||||
## Configuration |
||||
|
||||
![image](https://user-images.githubusercontent.com/20773151/67234502-ac171900-f41b-11e9-964e-c7d4cfadbd67.png) |
||||
|
||||
You can set the following configuration at `admin/config/islandora/core`: |
||||
- Broker URL |
||||
- The URL to your message broker (i.e. Activemq) |
||||
- JWT Expiry |
||||
- Set to increase the amount of time that authorization tokens remain valid. If you have a long running derivative processes or a migration, you may need to set this to be a very long time, e.g. `500d`. Otherwise, it's best to leave it alone. |
||||
- Gemini URL |
||||
- The URL to your Gemini server, which keeps track of where Islandora content is in Fedora. |
||||
- Fedora URL Display |
||||
- Selected bundles can display the Fedora URL for repository content. |
||||
|
||||
## Documentation |
||||
|
||||
Further documentation for this module is available on the [Islandora 8 documentation site](https://islandora.github.io/documentation/). |
||||
|
||||
## Troubleshooting/Issues |
||||
|
||||
Having problems or solved a problem? Check out the Islandora google groups for a solution. |
||||
|
||||
* [Islandora Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora) |
||||
* [Islandora Dev Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora-dev) |
||||
|
||||
## Maintainers |
||||
|
||||
Current maintainers: |
||||
|
||||
* [Islandora Technical Advisory Group](https://github.com/Islandora/islandora-community/wiki/Technical-Advisory-Group-%28TAG%29) |
||||
|
||||
## Sponsors |
||||
|
||||
* [American Philosophical Society](https://www.amphilsoc.org/) |
||||
* [Born-Digital, Inc.](https://www.born-digital.com/) |
||||
* [discoverygarden inc.](https://www.discoverygarden.ca/) |
||||
* [LYRASIS](https://www.lyrasis.org/) |
||||
* [McMaster University](https://www.mcmaster.ca/) |
||||
* [PALS](https://www.mnpals.org/) |
||||
* [University of Limerick](https://www.ul.ie/) |
||||
* [University of Manitoba](https://umanitoba.ca/) |
||||
* [UPEI](https://www.upei.ca/) |
||||
* [Simon Fraser University](https://www.sfu.ca/) |
||||
* [York University](https://www.yorku.ca/) |
||||
|
||||
## Development |
||||
|
||||
If you would like to contribute, please get involved by attending our weekly [Tech Call](https://github.com/Islandora/islandora-community/wiki/Weekly-Open-Tech-Call). We love to hear from you! |
||||
|
||||
If you would like to contribute code to the project, you need to be covered by an Islandora Foundation [Contributor License Agreement](https://github.com/Islandora/islandora-community/wiki/Onboarding-Checklist#contributor-license-agreements) or [Corporate Contributor License Agreement](https://github.com/Islandora/islandora-community/wiki/Onboarding-Checklist#contributor-license-agreements). Please see the [Contributor License Agreements](https://github.com/Islandora/islandora-community/wiki/Contributor-License-Agreements) page on the islandora-community wiki for more information. |
||||
|
||||
We recommend using the [islandora-playbook](https://github.com/Islandora-Devops/islandora-playbook) to get started. |
||||
|
||||
## License |
||||
|
||||
[GPLv2](http://www.gnu.org/licenses/gpl-2.0.txt) |
||||
|
@ -0,0 +1,211 @@
|
||||
<?php |
||||
|
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* SecurityClass Class |
||||
*/ |
||||
|
||||
/** |
||||
* SecurityClass ?? |
||||
*/ |
||||
class SecurityClass { |
||||
|
||||
public static $SECURITY_CLASS_SECURITY_STREAM = 'POLICY'; |
||||
|
||||
/** |
||||
* Constructor |
||||
*/ |
||||
function SecurityClass() { |
||||
module_load_include('inc', 'SecurityClass', ''); |
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
||||
} |
||||
|
||||
/** |
||||
* canIngestHere ?? |
||||
* @global type $user |
||||
* @param type $collection_pid |
||||
* @return type |
||||
*/ |
||||
function canIngestHere($collection_pid) { |
||||
global $user; |
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
$objectHelper = new ObjectHelper(); |
||||
// get the childsecurity policy from the collection. |
||||
$policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS :: $SECURITY_CLASS_SECURITY_STREAM, FALSE); |
||||
if ($policyStream == NULL) { |
||||
// no child policy stream so collection is wide open to anyone to ingest, that has the permission ingest in Drupal. |
||||
// maybe we should return FALSE here?? would be more secure. |
||||
return TRUE; |
||||
} |
||||
$allowedUsersAndRoles = $this->getAllowedUsersAndRoles($policyStream); |
||||
if (!$allowedUsersAndRoles) { |
||||
// error processing stream so don't let them ingest here. |
||||
return FALSE; |
||||
} |
||||
$allowedUsers = $allowedUsersAndRoles["users"]; |
||||
$allowedRoles = $allowedUsersAndRoles["roles"]; |
||||
|
||||
foreach ($user->roles as $role) { |
||||
if (in_array($role, $allowedRoles)) { |
||||
return TRUE; |
||||
} |
||||
} |
||||
|
||||
if (in_array($user->name, $allowedUsers)) { |
||||
return TRUE; |
||||
} |
||||
return FALSE; |
||||
} |
||||
|
||||
/** |
||||
* parses our simple xacml policies checking for users or roles that are allowed to ingest |
||||
* @param type $policyStream |
||||
* @return type |
||||
*/ |
||||
function getAllowedUsersAndRoles($policyStream) { |
||||
$allowedRoles = array(); |
||||
$allowedUsers = array(); |
||||
$usersAndRoles = array(); |
||||
try { |
||||
$xml = new SimpleXMLElement($policyStream); |
||||
} catch (Exception $e) { |
||||
watchdog(t("fedora_repository"), "No roles found in security policy, could not parse policy stream.", NULL, WATCHDOG_ERROR); |
||||
//we may not want to send this to the screen. |
||||
drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => check_plain($e->getMessage()))), 'error'); |
||||
return NULL; |
||||
} |
||||
$xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy'); |
||||
|
||||
$roles = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="fedoraRole"]/../default:Apply/default:AttributeValue'); |
||||
$users = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="urn:fedora:names:fedora:2.1:subject:loginId"]/../default:Apply/default:AttributeValue'); |
||||
|
||||
if($roles) { |
||||
foreach($roles as $role) { |
||||
$allowedRoles[] = (string)$role; |
||||
} |
||||
} |
||||
if($users) { |
||||
foreach($users as $user) { |
||||
$allowedUsers[] = (string)$user; |
||||
} |
||||
} |
||||
|
||||
$usersAndRoles['users'] = $allowedUsers; |
||||
$usersAndRoles['roles'] = $allowedRoles; |
||||
|
||||
return $usersAndRoles; |
||||
} |
||||
|
||||
/** |
||||
* When a user's profile is saved in drupal we will attempt to create a collection for them in Fedora |
||||
* this will be their personal space. In the IR it is editable by users with the same role in the VRE |
||||
* it probably would not be. |
||||
* @param type $user |
||||
* @return DOMDocument |
||||
*/ |
||||
function createPersonalPolicy($user) { |
||||
$doc = new DOMDocument(); |
||||
try { |
||||
$doc->load(drupal_get_path('module', 'fedora_repository') . '/policies/noObjectEditPolicy.xml'); |
||||
} catch (exception $e) { |
||||
watchdog(t("fedora_repository"), "Problem loading policy file.", NULL, WATCHDOG_ERROR); |
||||
} |
||||
$conditions = $doc->getElementsByTagName('Condition'); |
||||
foreach ($conditions as $condition) { |
||||
$designator = $condition->getElementsByTagName('SubjectAttributeDesignator'); |
||||
foreach ($designator as $des) { |
||||
$attributeId = $des->getAttribute('AttributeId'); |
||||
if ($attributeId == 'fedoraRole') { |
||||
$applies = $condition->getElementsByTagName('Apply'); |
||||
foreach ($applies as $apply) { |
||||
$functionId = $apply->getAttribute('FunctionId'); |
||||
if ($functionId == 'urn:oasis:names:tc:xacml:1.0:function:string-bag') { |
||||
foreach ($user->roles as $role) { |
||||
if (!($role == 'authenticated user' || $role == 'administrator')) { //don't want authenticated user included administrator already is included' |
||||
$newAttributeValue = $doc->createElement('AttributeValue', '<![CDATA[' . $role . ']]>'); |
||||
$newAttributeValue->setAttribute('DataType', 'http://www.w3.org/2001/XMLSchema#string'); |
||||
// $newAttributeValue->setAttribute('MustBePresent', 'FALSE'); |
||||
$apply->appendChild($newAttributeValue); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($attributeId == 'urn:fedora:names:fedora:2.1:subject:loginId') { |
||||
$applies = $condition->getElementsByTagName('Apply'); |
||||
foreach ($applies as $apply) { |
||||
$functionId = $apply->getAttribute('FunctionId'); |
||||
if ($functionId == 'urn:oasis:names:tc:xacml:1.0:function:string-bag') { |
||||
$newAttributeValue = $doc->createElement('AttributeValue', $user->name); |
||||
$newAttributeValue->setAttribute('DataType', 'http://www.w3.org/2001/XMLSchema#string'); |
||||
//$newAttributeValue->setAttribute('MustBePresent', 'FALSE'); |
||||
$apply->appendChild($newAttributeValue); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return $doc; //NULL; //$xml; |
||||
} |
||||
|
||||
/** |
||||
* Add a list of allowed users and roles to the given policy stream and return it. |
||||
* |
||||
* @param string $policy_stream |
||||
* @param array $users_and_roles |
||||
* @return DOMDocument |
||||
*/ |
||||
function set_allowed_users_and_roles(&$policy_stream, $users_and_roles) { |
||||
$allowed_roles = $users_and_roles['roles']; |
||||
$allowed_users = $users_and_roles['users']; |
||||
$dom = new DOMDocument(); |
||||
$dom->loadXML($policy_stream); |
||||
$conditions = $dom->getElementsByTagName('Condition'); |
||||
foreach ($conditions as $condition) { |
||||
$designator = $condition->getElementsByTagName('SubjectAttributeDesignator'); |
||||
foreach ($designator as $des) { |
||||
$attributeId = $des->getAttribute('AttributeId'); |
||||
if ($attributeId == 'fedoraRole') { |
||||
// $applies = $condition->getElementsByTagName('Apply'); |
||||
$applies = $des->parentNode->getElementsByTagName('Apply'); |
||||
foreach ($applies as $apply) { |
||||
$functionId = $apply->getAttribute('FunctionId'); |
||||
if ($functionId == 'urn:oasis:names:tc:xacml:1.0:function:string-bag') { |
||||
foreach ($allowed_roles as $role) { |
||||
if (!($role == 'authenticated user' || $role == 'administrator')) { //don't want authenticated user included administrator already is included' |
||||
$newAttributeValue = $dom->createElement('AttributeValue', $role); |
||||
$newAttributeValue->setAttribute('DataType', 'http://www.w3.org/2001/XMLSchema#string'); |
||||
//$newAttributeValue->setAttribute('MustBePresent', 'FALSE'); |
||||
$apply->appendChild($newAttributeValue); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($attributeId == 'urn:fedora:names:fedora:2.1:subject:loginId') { |
||||
// $applies = $condition->getElementsByTagName('Apply'); |
||||
$applies = $des->parentNode->getElementsByTagName('Apply'); |
||||
foreach ($applies as $apply) { |
||||
$functionId = $apply->getAttribute('FunctionId'); |
||||
if ($functionId == 'urn:oasis:names:tc:xacml:1.0:function:string-bag') { |
||||
foreach ($allowed_users as $username) { |
||||
$newAttributeValue = $dom->createElement('AttributeValue', $username); |
||||
$newAttributeValue->setAttribute('DataType', 'http://www.w3.org/2001/XMLSchema#string'); |
||||
//$newAttributeValue->setAttribute('MustBePresent', 'FALSE'); |
||||
$apply->appendChild($newAttributeValue); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
// $this->collection_policy_stream = $dom->saveXML(); |
||||
return $dom->saveXML(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,284 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* @file |
||||
* XMLDatastream Abstract Class |
||||
*/ |
||||
|
||||
/** |
||||
* XMLDatastream class ?? |
||||
*/ |
||||
abstract class XMLDatastream { |
||||
|
||||
static $XMLNS = 'http://www.islandora.ca'; |
||||
static $errors = NULL; |
||||
protected $xml = NULL; |
||||
private $valid = NULL; |
||||
protected $forceSchema = FALSE; // if set, the datastream will be validated against the specified schema in self::$SCHEMA_URI instead of |
||||
// reading the schema URI from the datastream. |
||||
public $pid; |
||||
public $dsid; |
||||
|
||||
/** |
||||
* Parses an PID from an identifier. |
||||
* @param string $identifier |
||||
* @return string $pid |
||||
*/ |
||||
public static function getPidFromIdentifier($identifier) { |
||||
return substr($identifier, 0, strpos($identifier, "/")); |
||||
} |
||||
|
||||
/** |
||||
* valid_pid |
||||
* Validates a fedora PID based on the regexp provided in the fedora |
||||
* 3.3 documentation. |
||||
* http://www.fedora-commons.org/confluence/display/FCR30/Fedora+Identifiers |
||||
* |
||||
* @param String $pid |
||||
* @return boolean $valid |
||||
*/ |
||||
public static function valid_pid($pid) { |
||||
$valid = FALSE; |
||||
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { |
||||
$valid = TRUE; |
||||
} |
||||
|
||||
return $valid; |
||||
} |
||||
|
||||
/** |
||||
* valid_dsid |
||||
* Validates a fedora Dsid based on the the allowed XML standard NCName. |
||||
* The regexp is a "regular" subset of names allowed, it excludes some extended hex characters that are |
||||
* technically permitted. |
||||
* http://www.fedora-commons.org/confluence/display/FCR30/Fedora+Identifiers |
||||
* |
||||
* @param String $pid |
||||
* @return boolean $valid |
||||
*/ |
||||
public static function valid_dsid($dsid) { |
||||
$valid = FALSE; |
||||
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { |
||||
$valid = TRUE; |
||||
} |
||||
|
||||
return $valid; |
||||
} |
||||
|
||||
/** |
||||
* Parses the DSID from an identifier. |
||||
* TODO: combine this method with getPidFromIdentifier? |
||||
* @param string $identifier |
||||
* @return string $dsid |
||||
*/ |
||||
public static function getDSIDFromIdentifier($identifier) { |
||||
$temp = strstr($identifier, "/"); |
||||
return substr($temp, 1); |
||||
} |
||||
|
||||
/** |
||||
* Constructs an XMLDatastream object from the XML file specified. |
||||
* Returns FALSE on failure. |
||||
* |
||||
* @param string $filename |
||||
* @return XMLDatastream $cm |
||||
*/ |
||||
public static function loadFromFile($filename) { |
||||
return new self(file_get_contents($filename)); |
||||
} |
||||
|
||||
/** |
||||
* Constructor |
||||
* NOTE: Use the static constructor methods whenever possible. |
||||
* |
||||
* @param string $xmlStr |
||||
* @param string $pid |
||||
* @param string $dsid |
||||
* @return XMLDatastream $cm |
||||
*/ |
||||
public function __construct($xmlStr, $pid = NULL, $dsid = NULL) { |
||||
libxml_use_internal_errors(TRUE); |
||||
|
||||
$this->pid = $pid; |
||||
$this->dsid = $dsid; |
||||
if ($xmlStr !== NULL) { |
||||
if (is_object($xmlStr) && get_class($xmlStr) == DOMDocument) { |
||||
$this->xml = $xmlStr; |
||||
} |
||||
else { |
||||
$this->xml = new DOMDocument(); |
||||
$this->xml->loadXML($xmlStr); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Gets the identifier for this XMLDatastream |
||||
* Returns FALSE on failure. |
||||
* |
||||
* NOTE: not available if constructed directly from file. |
||||
* |
||||
* @return string identifier |
||||
*/ |
||||
public function getIdentifier() { |
||||
return ($this->pid != NULL && $this->dsid != NULL) ? $this->pid . '/' . $this->dsid : FALSE; |
||||
} |
||||
|
||||
/** |
||||
* Dumps the XMLDatastream as an XML String |
||||
* |
||||
* |
||||
* @return string xml |
||||
*/ |
||||
public function dumpXml() { |
||||
if ($this->xml == NULL) { |
||||
$this->fetchXml(); |
||||
} |
||||
return $this->xml->saveXml(); |
||||
} |
||||
|
||||
/** |
||||
* Validates the XMLDatastream against the schema location |
||||
* defined by the xmlns:schemaLocation attribute of the root |
||||
* element. If the xmlns:schemaLocation attribute does not exist, |
||||
* then it is assumed to be the old schema and it attempts to convert |
||||
* using the convertFromOldSchema method. |
||||
* |
||||
* TODO: Maybe change it so that it always validates against a known |
||||
* schema. This makes more sense because this class assumes the structure |
||||
* to be known after it has been validated. |
||||
* |
||||
* @return boolean $valid |
||||
*/ |
||||
public function validate() { |
||||
global $user; |
||||
if ($this->valid === NULL) { |
||||
$ret = TRUE; |
||||
if ($this->xml == NULL) { |
||||
$this->fetchXml(); |
||||
} |
||||
// figure out if we're dealing with a new or old schema |
||||
$rootEl = $this->xml->firstChild; |
||||
if (!$rootEl->hasAttributes() || $rootEl->attributes->getNamedItem('schemaLocation') === NULL) { |
||||
//$tmpname = substr($this->pid, strpos($this->pid, ':') + 1); |
||||
$tmpname = user_password(10); |
||||
$this->convertFromOldSchema(); |
||||
drupal_add_js("fedora_repository_print_new_schema_$tmpname = function(tagID) { |
||||
var target = document.getElementById(tagID); |
||||
var content = target.innerHTML; |
||||
var text = '<html><head><title>Title' + |
||||
'</title><body>' + content +'</body></html>'; |
||||
printerWindow = window.open('', '', 'toolbar=no,location=no,' + 'status=no,menu=no,scrollbars=yes,width=650,height=400'); |
||||
printerWindow.document.open(); |
||||
printerWindow.document.write(text); |
||||
}", 'inline'); |
||||
|
||||
if (user_access('administer site configuration')) { |
||||
drupal_set_message('<span id="new_schema_' . $tmpname . '" style="display: none;">' . htmlentities($this->xml->saveXML()) . '</span>Warning: XMLDatastream performed conversion of \'' . $this->getIdentifier() . '\' from old schema. Please update the datastream. The new datastream contents are <a href="javascript:fedora_repository_print_new_schema_' . $tmpname . '(\'new_schema_' . $tmpname . '\')">here.</a> '); |
||||
} |
||||
|
||||
$rootEl = $this->xml->firstChild; |
||||
} |
||||
|
||||
$schemaLocation = NULL; |
||||
if ($this->forceSchema) { |
||||
// hack because you cant easily get the static property value from |
||||
// a subclass. |
||||
$vars = get_class_vars(get_class($this)); |
||||
$schemaLocation = $vars['SCHEMA_URI']; |
||||
} |
||||
elseif ($rootEl->attributes->getNamedItem('schemaLocation') !== NULL) { |
||||
//figure out where the schema is located and validate. |
||||
list(, $schemaLocation) = preg_split('/\s+/', $rootEl->attributes->getNamedItem('schemaLocation')->nodeValue); |
||||
} |
||||
$schemaLocation = NULL; |
||||
return TRUE; |
||||
if ($schemaLocation !== NULL) { |
||||
if (!$this->xml->schemaValidate($schemaLocation)) { |
||||
$ret = FALSE; |
||||
$errors = libxml_get_errors(); |
||||
foreach ($errors as $err) { |
||||
self::$errors[] = 'XML Error: Line ' . $err->line . ': ' . $err->message; |
||||
} |
||||
} |
||||
else { |
||||
$this->name = $rootEl->attributes->getNamedItem('name')->nodeValue; |
||||
} |
||||
} |
||||
else { |
||||
$ret = FALSE; |
||||
self::$errors[] = 'Unable to load schema.'; |
||||
} |
||||
|
||||
$this->valid = $ret; |
||||
} |
||||
|
||||
return $this->valid; |
||||
} |
||||
|
||||
/** |
||||
* Saves the current XML datastream back to fedora. The XML must validate. |
||||
* |
||||
* @return boolean $success |
||||
*/ |
||||
public function saveToFedora() { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
if ($this->validate()) { |
||||
$item = new Fedora_Item($this->pid); |
||||
$item->modify_datastream_by_value($this->dumpXml(), $this->dsid, $this->name, 'application/xml'); |
||||
return TRUE; |
||||
} |
||||
return FALSE; |
||||
} |
||||
|
||||
/** |
||||
* Purges veersions of the datastream newer than and including the start_date. If |
||||
* End date is specified, it can be used to purge a range of versions instead. Date should be in |
||||
* DATE_RFC822 format |
||||
* |
||||
* @param string $start_date |
||||
* @param string $end_date |
||||
* @return boolean $valid |
||||
*/ |
||||
public function purgeVersions($start_date, $end_date = NULL) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$fedora_item = new Fedora_Item($this->pid); |
||||
return $fedora_item->purge_datastream($this->dsid, $start_date, $end_date); |
||||
} |
||||
|
||||
/** |
||||
* Gets the history of the datastream from fedora. |
||||
* Returns FALSE on failure. |
||||
* |
||||
* @return string[] $ret |
||||
*/ |
||||
public function getHistory() { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$fedora_item = new Fedora_Item($this->pid); |
||||
$history = $fedora_item->get_datastream_history($this->dsid); |
||||
|
||||
$ret = FALSE; |
||||
if ($history !== FALSE) { |
||||
$ret = array(); |
||||
foreach ($history as $version) { |
||||
if ($version->versionID !== NULL) |
||||
$ret[] = array('versionID' => $version->versionID, 'createDate' => $version->createDate); |
||||
} |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
/** |
||||
* Attempts to convert from the old XML schema to the new by |
||||
* traversing the XML DOM and building a new DOM. When done |
||||
* $this->xml is replaced by the newly created DOM.. |
||||
* |
||||
* @return void |
||||
*/ |
||||
abstract protected function convertFromOldSchema(); |
||||
} |
@ -0,0 +1,139 @@
|
||||
<?php |
||||
|
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* Implements a simple class for working with Dublin Core data and exporting it |
||||
* back to XML. Inspiration and design shamelessly stolen from the pyfedora |
||||
* project at http://pypi.python.org/pypi/pyfedora/0.1.0 |
||||
*/ |
||||
|
||||
/** |
||||
* Dublin Core Class |
||||
*/ |
||||
class Dublin_Core { |
||||
|
||||
public $dc = array( |
||||
'dc:title' => array(), |
||||
'dc:creator' => array(), |
||||
'dc:subject' => array(), |
||||
'dc:description' => array(), |
||||
'dc:publisher' => array(), |
||||
'dc:contributor' => array(), |
||||
'dc:date' => array(), |
||||
'dc:type' => array(), |
||||
'dc:format' => array(), |
||||
'dc:identifier' => array(), |
||||
'dc:source' => array(), |
||||
'dc:language' => array(), |
||||
'dc:relation' => array(), |
||||
'dc:coverage' => array(), |
||||
'dc:rights' => array(), |
||||
); |
||||
public $owner; |
||||
|
||||
/** |
||||
* Constructs a Dublin_Core object from a Fedora_Item object and populates |
||||
* the $dc array. |
||||
* @param <type> $item |
||||
*/ |
||||
function Dublin_Core($item = NULL) { |
||||
if (!empty($item)) { |
||||
$this->owner = $item; |
||||
$dc_xml = $item->get_datastream_dissemination('DC'); |
||||
$this->dc = self::import_from_xml_string($dc_xml)->dc; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Add Elements |
||||
* @param <type> $element_name |
||||
* @param <type> $value |
||||
*/ |
||||
function add_element($element_name, $value) { |
||||
if (is_string($value) && is_array($this->dc[$element_name])) { |
||||
$this->dc[$element_name][] = $value; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Replace the given DC element with the values in $values |
||||
* @param string $elemnt_name |
||||
* @param array $values |
||||
*/ |
||||
function set_element($element_name, $values) { |
||||
if (is_array($values)) { |
||||
$this->dc[$element_name] = $values; |
||||
} |
||||
elseif (is_string($values)) { |
||||
$this->dc[$element_name] = array($values); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Serialize this object to XML and return it. |
||||
* @param type $with_preamble |
||||
* @return type |
||||
*/ |
||||
function as_xml($with_preamble = FALSE) { |
||||
$dc_xml = new DomDocument(); |
||||
$oai_dc = $dc_xml->createElementNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'oai_dc:dc'); |
||||
$oai_dc->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); |
||||
foreach ($this->dc as $dc_element => $values) { |
||||
if (is_array($values) && !empty($values)) { |
||||
foreach ($values as $value) { |
||||
$new_item = $dc_xml->createElement($dc_element, $value); |
||||
$oai_dc->appendChild($new_item); |
||||
} |
||||
} |
||||
else { |
||||
$new_item = $dc_xml->createElement($dc_element); |
||||
$oai_dc->appendChild($new_item); |
||||
} |
||||
} |
||||
$dc_xml->appendChild($oai_dc); |
||||
return $dc_xml->saveXML(); |
||||
} |
||||
|
||||
/** |
||||
* Create dc from dict ( does nothing ) |
||||
*/ |
||||
static function create_dc_from_dict() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Save ?? |
||||
* @param type $alt_owner |
||||
*/ |
||||
function save($alt_owner = NULL) { |
||||
$item_to_update = (!empty($alt_owner) ? $alt_owner : $this->owner); |
||||
// My Java roots showing, trying to do polymorphism in PHP. |
||||
if (!empty($item_to_update)) { |
||||
$item_to_update->modify_datastream_by_value($this->as_xml(), 'DC', 'Default Dublin Core Metadata', 'text/xml'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Creates a new instance of the class by parsing dc_xml |
||||
* @param string $dc_xml |
||||
* @return Dublin_Core |
||||
*/ |
||||
static function import_from_xml_string($dc_xml) { |
||||
$dc_doc = new DomDocument(); |
||||
if ($dc_doc->loadXML($dc_xml)) { |
||||
$oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*'); |
||||
$new_dc = new Dublin_Core(); |
||||
foreach ($oai_dc as $child) { |
||||
array_push($new_dc->dc[$child->nodeName], $child->nodeValue); |
||||
} |
||||
return $new_dc; |
||||
} |
||||
else { |
||||
return NULL; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,144 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Operations that affect a Fedora repository at a collection level. |
||||
*/ |
||||
module_load_include('inc', 'fedora_repository', 'CollectionClass'); |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
||||
module_load_include('module', 'fedora_repository'); |
||||
|
||||
/** |
||||
* Exports a fedora collection object and all of its children in a format |
||||
* that will let you import them into another repository. |
||||
* @param type $collection_pid |
||||
* @param type $relationship |
||||
* @param type $format |
||||
* @return type |
||||
*/ |
||||
function export_collection($collection_pid, $relationship = 'isMemberOfCollection', $format = 'info:fedora/fedora-system:FOXML-1.1') { |
||||
$collection_item = new Fedora_Item($collection_pid); |
||||
$foxml = $collection_item->export_as_foxml(); |
||||
|
||||
$file_dir = file_directory_path(); |
||||
|
||||
// Create a temporary directory to contain the exported FOXML files. |
||||
$container = tempnam($file_dir, 'export_'); |
||||
file_delete($container); |
||||
print $container; |
||||
if (mkdir($container) && mkdir($container . '/' . $collection_pid)) { |
||||
$foxml_dir = $container . '/' . $collection_pid; |
||||
$file = fopen($foxml_dir . '/' . $collection_pid . '.xml', 'w'); |
||||
fwrite($file, $foxml); |
||||
fclose($file); |
||||
|
||||
$member_pids = get_related_items_as_array($collection_pid, $relationship); |
||||
foreach ($member_pids as $member) { |
||||
$file = fopen($foxml_dir . '/' . $member . '.xml', 'w'); |
||||
$item = new Fedora_Item($member); |
||||
$item_foxml = $item->export_as_foxml(); |
||||
fwrite($file, $item_foxml); |
||||
fclose($file); |
||||
} |
||||
if (system("cd $container;zip -r $collection_pid.zip $collection_pid/* >/dev/null") == 0) { |
||||
header("Content-type: application/zip"); |
||||
header('Content-Disposition: attachment; filename="' . $collection_pid . '.zip' . '"'); |
||||
$fh = fopen($container . '/' . $collection_pid . '.zip', 'r'); |
||||
$the_data = fread($fh, filesize($container . '/' . $collection_pid . '.zip')); |
||||
fclose($fh); |
||||
echo $the_data; |
||||
} |
||||
if (file_exists($container . '/' . $collection_pid)) { |
||||
system("rm -rf $container"); // I'm sorry. |
||||
} |
||||
} |
||||
else { |
||||
drupal_set_message(t("Error creating temp directory for batch export."), 'error'); |
||||
return FALSE; |
||||
} |
||||
return TRUE; |
||||
} |
||||
|
||||
/** |
||||
* Returns an array of pids that match the query contained in teh collection |
||||
* object's QUERY datastream or in the suppled $query parameter. |
||||
* @param <type> $collection_pid |
||||
* @param <type> $query |
||||
* @param <type> $query_format R |
||||
*/ |
||||
function get_related_items_as_xml($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { |
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
|
||||
if (!fedora_repository_check_perm(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid)) { |
||||
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); |
||||
return array(); |
||||
} |
||||
|
||||
$query_string = 'select $object $title $content from <#ri> |
||||
where ($object <fedora-model:label> $title |
||||
and $object <fedora-model:hasModel> $content |
||||
and ('; |
||||
|
||||
if (is_array($relationship)) { |
||||
foreach ($relationship as $rel) { |
||||
$query_string .= '$object <fedora-rels-ext:' . $rel . '> <info:fedora/' . $collection_pid . '>'; |
||||
if (next($relationship)) { |
||||
$query_string .= ' OR '; |
||||
} |
||||
} |
||||
} |
||||
elseif (is_string($relationship)) { |
||||
$query_string .= '$object <fedora-rels-ext:' . $relationship . '> <info:fedora/' . $collection_pid . '>'; |
||||
} |
||||
else { |
||||
return ''; |
||||
} |
||||
|
||||
$query_string .= ') '; |
||||
$query_string .= $active_objects_only ? 'and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>' : ''; |
||||
|
||||
if ($cmodel) { |
||||
$query_string .= ' and $content <mulgara:is> <info:fedora/' . $cmodel . '>'; |
||||
} |
||||
|
||||
$query_string .= ') |
||||
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> |
||||
order by ' . $orderby; |
||||
|
||||
$query_string = htmlentities(urlencode($query_string)); |
||||
|
||||
|
||||
$content = ''; |
||||
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
||||
$url .= "?type=tuples&flush=TRUE&format=Sparql&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query_string; |
||||
$content .= do_curl($url); |
||||
|
||||
return $content; |
||||
} |
||||
|
||||
/** |
||||
* Get Related Items as Arrays |
||||
* @param type $collection_pid |
||||
* @param type $relationship |
||||
* @param type $limit |
||||
* @param type $offset |
||||
* @param type $active_objects_only |
||||
* @param type $cmodel |
||||
* @param type $orderby |
||||
* @return type |
||||
*/ |
||||
function get_related_items_as_array($collection_pid, $relationship = 'isMemberOfCollection', $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { |
||||
$content = get_related_items_as_xml($collection_pid, $relationship, $limit, $offset, $active_objects_only, $cmodel, $orderby); |
||||
if (empty($content)) { |
||||
return array(); |
||||
} |
||||
|
||||
$content = new SimpleXMLElement($content); |
||||
|
||||
$resultsarray = array(); |
||||
foreach ($content->results->result as $result) { |
||||
$resultsarray[] = substr($result->object->attributes()->uri, 12); // Remove 'info:fedora/'. |
||||
} |
||||
return $resultsarray; |
||||
} |
@ -0,0 +1,216 @@
|
||||
<?php |
||||
|
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* Fedora Export |
||||
*/ |
||||
define('FOXML_10', 'info:fedora/fedora-system:FOXML-1.0'); |
||||
define('FOXML_11', 'info:fedora/fedora-system:FOXML-1.1'); |
||||
define('METS_10', 'info:fedora/fedora-system:METSFedoraExt-1.0'); |
||||
define('METS_11', 'info:fedora/fedora-system:METSFedoraExt-1.1'); |
||||
define('ATOM_11', 'info:fedora/fedora-system:ATOM-1.1'); |
||||
define('ATOMZip_11', 'info:fedora/fedora-system:ATOMZip-1.1'); |
||||
|
||||
/** |
||||
* Function to to export all objects assocoiated with a given pid to the export area |
||||
* @param type $pid |
||||
* @param type $foxml_dir |
||||
* @param type $ob_dir |
||||
* @param type $log |
||||
* @return type |
||||
*/ |
||||
function export_to_export_area($pid, $foxml_dir, $ob_dir, &$log = array()) { |
||||
if (!$paths = export_objects_for_pid($pid, $ob_dir, $log)) { |
||||
return FALSE; |
||||
} |
||||
|
||||
if (!export_foxml_for_pid($pid, $foxml_dir, $paths, $log)) { |
||||
return FALSE; |
||||
} |
||||
|
||||
return TRUE; |
||||
} |
||||
|
||||
/** |
||||
* Export objects for pids ?? |
||||
* @param type $pid |
||||
* @param type $dir |
||||
* @param type $log |
||||
* @return string |
||||
*/ |
||||
function export_objects_for_pid($pid, $dir, &$log) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$item = new Fedora_Item($pid); |
||||
if (!$object = $item->get_datastreams_list_as_SimpleXML($pid)) { |
||||
$log[] = log_line(t("Failed to get datastream %dsid for pid %pid", array('%dsid' => $ds->ID, '%pid' => $pid)), 'error'); |
||||
return FALSE; |
||||
} |
||||
|
||||
// Datastreams added as a result of the ingest process |
||||
$ignore_dsids = array('QUERY'); |
||||
|
||||
$paths = array(); |
||||
foreach ($object->datastreamDef as $ds) { |
||||
if (!in_array($ds->ID, $ignore_dsids)) { |
||||
$file = $dir . '/' . $ds->label . '.' . get_file_extension($ds->MIMEType); |
||||
$paths[$ds->ID] = $file; |
||||
|
||||
if ($content = $ob_helper->getStream($pid, $ds->ID, FALSE)) { |
||||
if (!$fp = @fopen($file, 'w')) { |
||||
$log[] = log_line(t("Failed to open file %file to write datastream %dsid for pid %pid", array('%file' => $file, '%dsid' => $ds->ID, '%pid' => $pid)), 'error'); |
||||
return FALSE; |
||||
} |
||||
fwrite($fp, $content); |
||||
fclose($fp); |
||||
} |
||||
else { |
||||
$log[] = log_line(t("Failed to get datastream %dsid for pid %pid", array('%dsid' => $ds->ID, '%pid' => $pid)), 'error'); |
||||
} |
||||
} |
||||
} |
||||
return $paths; |
||||
} |
||||
|
||||
/** |
||||
* Export foxml for pid |
||||
* @param type $pid |
||||
* @param type $dir |
||||
* @param type $paths |
||||
* @param type $log |
||||
* @param type $format |
||||
* @param type $remove_islandora |
||||
* @return type |
||||
*/ |
||||
function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $remove_islandora = FALSE) { |
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
$ob_helper = new ObjectHelper(); |
||||
if (!$object_xml = $ob_helper->getObject($pid, 'migrate', $format)) { |
||||
$log[] = log_line(t("Failed to get foxml for %pid", array('%pid' => $pid)), 'error'); |
||||
return FALSE; |
||||
} |
||||
|
||||
$foxml = new DOMDocument(); |
||||
$foxml->loadXML($object_xml); |
||||
|
||||
$xpath = new DOMXpath($foxml); |
||||
|
||||
// Remove rdf elements added during ingest (if present) |
||||
if ($remove_islandora) { |
||||
$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); |
||||
$desc_node = $xpath->query("//rdf:RDF/rdf:Description")->item(0); |
||||
|
||||
if ($model = $desc_node->getElementsByTagName('hasModel')->item(0)) { |
||||
$desc_node->removeChild($model); |
||||
} |
||||
|
||||
if ($member = $desc_node->getElementsByTagName('rel:isMemberOfCollection')->item(0)) { |
||||
$desc_node->removeChild($member); |
||||
} |
||||
} |
||||
|
||||
if ($remove_islandora) { |
||||
// Update object paths in the foxml for this pid |
||||
switch ($format) { |
||||
case FOXML_10: |
||||
case FOXML_11: |
||||
|
||||
$disallowed_groups = array('E', 'R'); |
||||
|
||||
// Update datastream uris |
||||
$xpath->registerNamespace('foxml', 'info:fedora/fedora-system:def/foxml#'); |
||||
foreach ($xpath->query("//foxml:datastream[@ID]") as $ds_node) { |
||||
|
||||
// Don't update datastreams having external uris |
||||
if (in_array($ds_node->getAttribute('CONTROL_GROUP'), $disallowed_groups)) { |
||||
continue; |
||||
} |
||||
|
||||
$ds_id = $ds_node->getAttribute('ID'); |
||||
|
||||
// Remove QUERY datastream |
||||
if ($ds_id == "QUERY") { |
||||
$parent_node = $xpath->query('/foxml:digitalObject')->item(0); |
||||
$parent_node->removeChild($ds_node); |
||||
} |
||||
|
||||
foreach ($ds_node->getElementsByTagName('*') as $content_node) { |
||||
if ($str = $content_node->getAttribute('REF')) { |
||||
$content_node->setAttribute('REF', url($paths[$ds_id], array('absolute' => TRUE))); |
||||
} |
||||
} |
||||
} |
||||
break; |
||||
|
||||
case METS_10: |
||||
case METS_11: |
||||
// Update datastream uris |
||||
$xpath->registerNamespace('METS', 'http://www.loc.gov/METS/'); |
||||
foreach ($xpath->query('//METS:fileGrp[@ID="DATASTREAMS"]/METS:fileGrp') as $ds_node) { |
||||
|
||||
$ds_id = $ds_node->getAttribute('ID'); |
||||
|
||||
// Remove QUERY datastream |
||||
if ($ds_id == "QUERY") { |
||||
$parent_node = $xpath->query('//METS:fileGrp[@ID="DATASTREAMS"]')->item(0); |
||||
$parent_node->removeChild($ds_node); |
||||
} |
||||
|
||||
$xpath->registerNamespace('xlink', 'http://www.loc.gov/METS/'); |
||||
foreach ($xpath->query('METS:file[@OWNERID!="E"][@OWNERID!="R"]/METS:FLocat[@xlink:href]', $ds_node) as $floc) { |
||||
$floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => TRUE))); |
||||
} |
||||
/* |
||||
foreach ($ds_node->getElementsByTagName('METS:file') as $content_node) { |
||||
// Don't update datastreams having external uris |
||||
if (in_array($ds_node->getAttribute('OWNERID'), $disallowed_groups)) { |
||||
continue; |
||||
} |
||||
|
||||
foreach ($xpath->('METS:FLocat[@xlink:href]', $content_node) as $floc) { |
||||
$floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => TRUE))); |
||||
} |
||||
`} |
||||
*/ |
||||
} |
||||
|
||||
break; |
||||
|
||||
default: |
||||
$log[] = log_line(t("Unknown or invalid format: " . $format), 'error'); |
||||
return FALSE; |
||||
} |
||||
} //if $remove_islandora |
||||
|
||||
$file = $dir . '/' . $pid . '.xml'; |
||||
if (!$foxml->save($file)) { |
||||
$log[] = log_line(t("Failed to write datastream %dsid for pid %pid to %file", array('%dsid' => $ds->ID, '%pid' => $pid, '%file' => $file)), 'error'); |
||||
return FALSE; |
||||
} |
||||
else { |
||||
$log[] = log_line(t("Exported %pid to %file", array('%pid' => $pid, '%file' => $file)), 'info'); |
||||
} |
||||
|
||||
return TRUE; |
||||
} |
||||
|
||||
/** |
||||
* Get file extension |
||||
* @param type $mimeType |
||||
* @return type |
||||
*/ |
||||
function get_file_extension($mime_type) { |
||||
return substr(strstr($mime_type, '/'), 1); |
||||
} |
||||
|
||||
/** |
||||
* Log line |
||||
* @param type $msg |
||||
* @param type $severity |
||||
* @param type $sep |
||||
* @return type |
||||
*/ |
||||
function log_line($msg, $severity = 'info', $sep = "\t") { |
||||
return date("Y-m-d H:i:s") . $sep . ucfirst($severity) . $sep . $msg; |
||||
} |
@ -0,0 +1,373 @@
|
||||
<?php |
||||
/** |
||||
* @file |
||||
* Base utilities used by the Islandora fedora module. |
||||
*/ |
||||
|
||||
if (!function_exists('str_getcsv')) { |
||||
|
||||
/** |
||||
* Functions that emulate php5.3 functionality for backwards compatiablity |
||||
* |
||||
* @param type $input |
||||
* @param type $delimiter |
||||
* @param type $enclosure |
||||
* @param type $escape |
||||
* @param type $eol |
||||
* |
||||
* @return type |
||||
*/ |
||||
function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = NULL, $eol = NULL) { |
||||
$temp = fopen("php://memory", "rw"); |
||||
fwrite($temp, $input); |
||||
fseek($temp, 0); |
||||
$r = fgetcsv($temp, 4096, $delimiter, $enclosure); |
||||
fclose($temp); |
||||
return $r; |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* |
||||
* Utility method to get data from a url location using curl_exec and return |
||||
* |
||||
* This method takes identical parameters to do_curl_ext and passes them |
||||
* directly to do_curl_ext. The output from do_curl_ext is processed into |
||||
* either a TRUE, FALSE, or NULL value. |
||||
* |
||||
* This method exists for historical reasons as existing code makes use of |
||||
* do_curl directly and expects a simple return value and not an array. |
||||
* |
||||
* @param $url |
||||
* URL to be accessed by the function |
||||
* @param $return_to_variable |
||||
* Indicates whether the resource accessed by the curl call (HTML page, |
||||
* XML page, etc.) is returned directly from the function to the calling |
||||
* program or if it is sent directly to output. |
||||
* @param $number_of_post_vars |
||||
* Number of variable sot be posted |
||||
* @param $post |
||||
* Whether the curl_exec is done as a "get" or a "post" |
||||
* |
||||
* @return mixed |
||||
* TRUE, FALSE, NULL, or the data returned from accessing the URL |
||||
*/ |
||||
function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) { |
||||
$return_array = do_curl_ext($url, $return_to_variable, $number_of_post_vars, $post); |
||||
return ($return_array != NULL) ? $return_array[0] : NULL; |
||||
} |
||||
|
||||
/** |
||||
* Utility method to get data from a url location using curl_exec |
||||
* |
||||
* This method takes a URL and three associated parameters and initializes the |
||||
* structure required to make a call to curl_exec. As a part of the |
||||
* initialization the permissions associated with the (global) user are added |
||||
* to the call. This ensures access to any potentially user restricted URLs. |
||||
* |
||||
* Various defaults are used for the parameters required by curl_exec including |
||||
* the user agent and timeout. These are hard-coded. |
||||
* |
||||
* @param string $url |
||||
* URL to be accessed by the function |
||||
* @param $return_to_variable |
||||
* Indicates whether the resource accessed by the curl call (HTML page, |
||||
* XML page, etc.) is returned directly from the function to the calling |
||||
* program or if it is sent directly to output. |
||||
* @param $number_of_post_vars |
||||
* Number of variable sot be posted |
||||
* @param $post |
||||
* Whether the curl_exec is done as a "get" or a "post" |
||||
* |
||||
* @return mixed |
||||
* an array that consists of three value or NULL if curl is not suported: |
||||
* - element 0: |
||||
* The value returned from the curl_exec function call. |
||||
* This is either a boolean value or the actual data returned from |
||||
* accessing the URL. |
||||
* - element 1: |
||||
* The error code reslting from attempting to access the URL with curl_exec |
||||
* - element 2: |
||||
* A string representing a textual representation of the error code that |
||||
* resulted from attempting to access the URL with curl_exec |
||||
*/ |
||||
function do_curl_ext($url, $return_to_variable = TRUE, $number_of_post_vars = 0, $post = NULL) { |
||||
global $user; |
||||
|
||||
// Check if we are inside Drupal and there is a valid user. |
||||
// If the user is not valid for a Fedora call curl will throw an exception. |
||||
if ((!isset($user)) || $user->uid == 0) { |
||||
$fedora_user = 'anonymous'; |
||||
$fedora_pass = 'anonymous'; |
||||
} |
||||
else { |
||||
$fedora_user = $user->name; |
||||
$fedora_pass = $user->pass; |
||||
} |
||||
|
||||
if (function_exists("curl_init")) { |
||||
$ch = curl_init(); |
||||
$user_agent = "Mozilla/4.0 pp(compatible; MSIE 5.01; Windows NT 5.0)"; |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); |
||||
// Fail on errors. |
||||
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); |
||||
// Allow redirects. |
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
||||
// Times out after 90s. |
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 90); |
||||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); |
||||
// Return into a variable. |
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $return_to_variable); |
||||
curl_setopt($ch, CURLOPT_URL, $url); |
||||
curl_setopt($ch, CURLOPT_USERPWD, "$fedora_user:$fedora_pass"); |
||||
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
||||
if ($number_of_post_vars > 0 && $post) { |
||||
curl_setopt($ch, CURLOPT_POST, $number_of_post_vars); |
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "$post"); |
||||
} |
||||
|
||||
$ret_val = curl_exec($ch); |
||||
|
||||
$error_code = curl_errno($ch); |
||||
$error_string = curl_error($ch); |
||||
return array($ret_val, $error_code, $error_string); |
||||
} |
||||
else { |
||||
if (function_exists(drupal_set_message)) { |
||||
drupal_set_message(t('No curl support.'), 'error'); |
||||
} |
||||
return NULL; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Fedora available |
||||
* |
||||
* @return mixed |
||||
*/ |
||||
function fedora_available() { |
||||
|
||||
$response = do_curl_ext(variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/describe'); |
||||
return ($response != NULL) ? ($response[1] == 0) : FALSE; |
||||
} |
||||
|
||||
/** |
||||
* Resource index search available |
||||
* |
||||
* @return mixed |
||||
*/ |
||||
function risearch_available() { |
||||
|
||||
$response = do_curl_ext(variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch')); |
||||
return ($response != NULL) ? ($response[1] == 0) : FALSE; |
||||
} |
||||
|
||||
/** |
||||
* Returns a UTF-8-encoded transcripiton of the string given in $in_str. |
||||
* |
||||
* @param string $in_str |
||||
* |
||||
* @return string A UTF-8 encoded string. |
||||
*/ |
||||
function fix_encoding($in_str) { |
||||
$cur_encoding = mb_detect_encoding($in_str); |
||||
if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) { |
||||
return $in_str; |
||||
} |
||||
else { |
||||
return utf8_encode($in_str); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* valid pid ?? |
||||
* |
||||
* @param type $pid |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
function valid_pid($pid) { |
||||
$valid = FALSE; |
||||
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { |
||||
$valid = TRUE; |
||||
} |
||||
|
||||
return $valid; |
||||
} |
||||
|
||||
/** |
||||
* Valid Dsid ?? |
||||
* |
||||
* @param type $dsid |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
function valid_dsid($dsid) { |
||||
$valid = FALSE; |
||||
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { |
||||
$valid = TRUE; |
||||
} |
||||
|
||||
return $valid; |
||||
} |
||||
|
||||
/** |
||||
* fixDsid ?? |
||||
* |
||||
* @param type $dsid |
||||
* |
||||
* @return string |
||||
*/ |
||||
function fix_dsid($dsid) { |
||||
$new_dsid = trim($dsid); |
||||
|
||||
$find = '/[^a-zA-Z0-9\.\_\-]/'; |
||||
$replace = ''; |
||||
$new_dsid = preg_replace($find, $replace, $new_dsid); |
||||
|
||||
if (strlen($new_dsid) > 63) { |
||||
$new_dsid = substr($new_dsid, -63); |
||||
} |
||||
|
||||
if (preg_match('/^[^a-zA-Z]/', $dsid)) { |
||||
$new_dsid = 'x' . $new_dsid; |
||||
} |
||||
|
||||
if (strlen($new_dsid) == 0) { |
||||
$new_dsid = 'item' . rand(1, 100); |
||||
} |
||||
|
||||
return $new_dsid; |
||||
} |
||||
|
||||
/** |
||||
* Function: get_collections_as_option_array |
||||
* |
||||
* @return array |
||||
* Returns an associative array of all collection objects in Fedora instance |
||||
*/ |
||||
function get_collections_as_option_array() { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
||||
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); |
||||
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); |
||||
$namespaces = explode(':', $allowed_string); |
||||
$query = 'select $object $title from <#ri> |
||||
where ($object <fedora-model:label> $title |
||||
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> |
||||
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
||||
order by $title'; |
||||
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
||||
|
||||
$options = array( |
||||
'type' => 'tuples', |
||||
'flush' => 'TRUE', |
||||
'format' => 'csv', |
||||
'limit' => '1000', |
||||
'lang' => 'itql', |
||||
'stream' => 'on', |
||||
'query' => $query, |
||||
); |
||||
// The url function will take care of URL encoding. |
||||
$content = do_curl(url($url, array('query' => $options))); |
||||
|
||||
$list = explode("\n", $content); |
||||
array_shift($list); |
||||
$list = preg_replace('/info:fedora\//', '', $list); |
||||
foreach ($namespaces as $namespace) { |
||||
$trimmed_names[] = trim($namespace); |
||||
} |
||||
$options = array(); |
||||
// Removes blanks. |
||||
foreach ($list as $item) { |
||||
if ($item) { |
||||
$parts = explode(',', $item); |
||||
$namespace = explode(':', $parts[0]); |
||||
$namespace = trim($namespace[0]); |
||||
$bool = in_array($namespace, $trimmed_names); |
||||
if (!$restricted || in_array($namespace, $trimmed_names)) { |
||||
$options[$parts[0]] = $parts[1]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
unset($options['islandora:ContentModelCollection']); |
||||
return $options; |
||||
} |
||||
|
||||
/** |
||||
* Function: get_content_models_as_option_array |
||||
* |
||||
* @return array |
||||
* associative array of all available content models in Fedora instance |
||||
*/ |
||||
function get_content_models_as_option_array() { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
||||
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); |
||||
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); |
||||
$namespaces = explode(':', $allowed_string); |
||||
foreach ($namespaces as $namespace) { |
||||
if ($namespace) { |
||||
$allowed[] = trim($namespace); |
||||
} |
||||
} |
||||
$query = 'select $object $title from <#ri> |
||||
where ($object <fedora-model:label> $title |
||||
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> |
||||
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) |
||||
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
||||
order by $title'; |
||||
|
||||
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
||||
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; |
||||
$content = do_curl($url . htmlentities(urlencode($query))); |
||||
$list = explode("\n", $content); |
||||
array_shift($list); |
||||
$list = preg_replace('/info:fedora\//', '', $list); |
||||
// Removes blanks. |
||||
foreach ($list as $item) { |
||||
if ($item) { |
||||
$parts = explode(',', $item); |
||||
$nameparts = explode(':', $parts[0]); |
||||
if (!$restricted || in_array($nameparts[0], $allowed)) { |
||||
if (!preg_match('/fedora-system/', $nameparts[0])) { |
||||
$options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return $options; |
||||
} |
||||
|
||||
/** |
||||
* This function will retrieve the collections that the given PID belongs to. |
||||
* |
||||
* @param string $PID |
||||
* The PID to find the parents of. |
||||
* |
||||
* @return array |
||||
* $object_PIDs the list of PIDs of the collections that the |
||||
* indicated object is a member of. |
||||
*/ |
||||
function get_parent_collections_from_pid($PID) { |
||||
$query_string = 'select $parent from <#ri> |
||||
where ($object <fedora-rels-ext:isMemberOf> $parent |
||||
or $object <fedora-rels-ext:isMemberOfCollection> $parent) |
||||
and $object <dc:identifier> \'' . $PID . '\' |
||||
order by $object'; |
||||
|
||||
$query_string = htmlentities(urlencode($query_string)); |
||||
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
||||
$url .= '?type=tuples&flush=true&format=csv&limit=13000&lang=itql&stream=on&query=' . $query_string; |
||||
|
||||
$content = do_curl($url, TRUE); |
||||
|
||||
$results = explode("\n", $content); |
||||
$object_PIDs = preg_replace('/^info:fedora\/|"parent"| /', '', $results); |
||||
$object_PIDs = array_values(array_filter($object_PIDs)); |
||||
|
||||
return $object_PIDs; |
||||
} |
@ -0,0 +1,46 @@
|
||||
<?php |
||||
|
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* RelsExt class |
||||
*/ |
||||
|
||||
/** |
||||
* RelsExt class |
||||
*/ |
||||
class RelsExt { |
||||
|
||||
// Instance variables |
||||
public $relsExtArray = array(); |
||||
private $originalRelsExtArray = array(); // Used to determine the result of modified() funciton. |
||||
|
||||
/** |
||||
* Constructor that builds itself by retrieving the RELS-EXT stream from |
||||
* the repository for the given Fedora_Item. |
||||
* @param Fedora_Item $item |
||||
*/ |
||||
function RelsExt($item) { |
||||
$relsextxml = $item->get_datastream_dissemination('RELS-EXT'); |
||||
} |
||||
|
||||
/** |
||||
* modified |
||||
* @return type |
||||
*/ |
||||
function modified() { |
||||
return!(empty(array_diff($this->relsExtArray, $this->originalRelsExtArray)) && |
||||
empty(array_diff($this->originalRelsExtArray, $this->relsExtArray))); |
||||
} |
||||
|
||||
/** |
||||
* Save the current state of the RELS-EXT array out to the repository item |
||||
* as a datastream. |
||||
*/ |
||||
function save() { |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,78 @@
|
||||
<?php |
||||
|
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* TagSet Class |
||||
*/ |
||||
|
||||
/** |
||||
* TagSet Class |
||||
*/ |
||||
class TagSet { |
||||
|
||||
public $tags = array(); |
||||
public $item = NULL; |
||||
public $tagsDSID = 'TAGS'; |
||||
|
||||
/** |
||||
* Constructor |
||||
* @param type $item |
||||
*/ |
||||
function TagSet($item = NULL) { |
||||
if (!empty($item) && get_class($item) == 'Fedora_Item') { |
||||
$this->item = $item; |
||||
$this->load(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Load ?? |
||||
* @return type |
||||
*/ |
||||
function load() { |
||||
$tagsxml = isset($this->item->datastreams[$this->tagsDSID]) ? $this->item->get_datastream_dissemination($this->tagsDSID) : NULL; |
||||
if (empty($tagsxml)) { |
||||
$this->tags = array(); |
||||
return FALSE; |
||||
} |
||||
$tagsdoc = new DOMDocument(); |
||||
$tagsdoc->loadXML($tagsxml); |
||||
$tags = $tagsdoc->getElementsByTagName('tag'); |
||||
foreach ($tags as $tag) { |
||||
$this->tags[] = array( |
||||
'name' => $tag->nodeValue, |
||||
'creator' => $tag->getAttribute('creator') |
||||
); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Saves an associative array of tags to a datastream. |
||||
*/ |
||||
function save() { |
||||
$tagdoc = new DomDocument(); |
||||
$e_tags = new DomElement('tags'); |
||||
$tagdoc->appendChild($e_tags); |
||||
foreach ($this->tags as $tag) { |
||||
$e_tag = $tagdoc->createElement('tag', $tag['name']); |
||||
$e_tag->setAttribute('creator', (!empty($tag['creator'])) ? $tag['creator'] : ''); |
||||
$e_tags->appendChild($e_tag); |
||||
} |
||||
try { |
||||
$datastreams = $this->item->get_datastreams_list_as_array(); |
||||
if (empty($datastreams[$this->tagsDSID])) { |
||||
$this->item->add_datastream_from_string($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X'); |
||||
} |
||||
else { |
||||
$this->item->modify_datastream_by_value($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X'); |
||||
} |
||||
} catch (exception $e) { |
||||
drupal_set_message(t('There was an error saving the tags datastream: @e'), array('@e' => $e), 'error'); |
||||
return FALSE; |
||||
} |
||||
return TRUE; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,115 @@
|
||||
<?php |
||||
|
||||
$islandora_module_path = drupal_get_path('module', 'fedora_repository'); |
||||
|
||||
//do this until we export these in a module or library |
||||
@include_once 'sites/all/libraries/tuque/Datastream.php'; |
||||
@include_once 'sites/all/libraries/tuque/FedoraApi.php'; |
||||
@include_once 'sites/all/libraries/tuque/FedoraApiSerializer.php'; |
||||
@include_once 'sites/all/libraries/tuque/Object.php'; |
||||
@include_once 'sites/all/libraries/tuque/RepositoryConnection.php'; |
||||
@include_once 'sites/all/libraries/tuque/Cache.php'; |
||||
@include_once 'sites/all/libraries/tuque/RepositoryException.php'; |
||||
@include_once 'sites/all/libraries/tuque/Repository.php'; |
||||
@include_once 'sites/all/libraries/tuque/FedoraRelationships.php'; |
||||
|
||||
@include_once "$islandora_module_path/libraries/tuque/Datastream.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/FedoraApi.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/FedoraApiSerializer.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/Object.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/RepositoryConnection.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/Cache.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/RepositoryException.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/Repository.php"; |
||||
@include_once "$islandora_module_path/libraries/tuque/FedoraRelationships.php"; |
||||
|
||||
class IslandoraTuque { |
||||
|
||||
/** |
||||
* Connection to the repository |
||||
* |
||||
* @var RepositoryConnection |
||||
*/ |
||||
public $connection = NULL; |
||||
|
||||
/** |
||||
* The Fedora API we are using |
||||
* |
||||
* @var FedoraAPI |
||||
*/ |
||||
public $api = NULL; |
||||
|
||||
/** |
||||
* The cache we use to connect. |
||||
* |
||||
* @var SimpleCache |
||||
*/ |
||||
public $cache = NULL; |
||||
|
||||
/** |
||||
* The repository object. |
||||
* |
||||
* @var FedoraRepository |
||||
*/ |
||||
public $repository = NULL; |
||||
|
||||
function __construct($user = NULL, $url = NULL) { |
||||
if(!isset($user)) { |
||||
global $user; |
||||
} |
||||
|
||||
if(!isset($user) || $user->uid == 0){ |
||||
$user_string = 'anonymous'; |
||||
$pass_string = 'anonymous'; |
||||
} else { |
||||
$user_string = $user->name; |
||||
$pass_string = $user->pass; |
||||
} |
||||
|
||||
if (!isset($url)) { |
||||
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora'); |
||||
} |
||||
|
||||
if(self::exists()) { |
||||
$this->connection = new RepositoryConnection($url, $user_string, $pass_string); |
||||
$this->connection->reuseConnection = TRUE; |
||||
$this->api = new FedoraApi($this->connection); |
||||
$this->cache = new SimpleCache(); |
||||
$this->repository = new FedoraRepository($this->api, $this->cache); |
||||
} |
||||
} |
||||
|
||||
static function exists() { |
||||
return class_exists('RepositoryConnection'); |
||||
} |
||||
|
||||
static function getError() { |
||||
$islandora_doc_link = l(t('Islandora documentation'), 'https://wiki.duraspace.org/display/ISLANDORA/Islandora'); |
||||
$tuque_link = l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'); |
||||
$message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array( '!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link)); |
||||
drupal_set_message($message, 'error', FALSE); |
||||
} |
||||
} |
||||
|
||||
function islandora_object_load($object_id) { |
||||
static $islandora_tuque = NULL; |
||||
|
||||
if(!$islandora_tuque) { |
||||
$islandora_tuque = new IslandoraTuque(); |
||||
} |
||||
|
||||
if(IslandoraTuque::exists()) { |
||||
try { |
||||
$fedora_object = $islandora_tuque->repository->getObject($object_id); |
||||
} catch (Exception $e) { |
||||
return NULL; |
||||
} |
||||
return $fedora_object; |
||||
} |
||||
else { |
||||
IslandoraTuque::getError(); |
||||
return NULL; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
|
||||
<collection_policy name="" xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> |
||||
<content_models> |
||||
<content_model dsid="ISLANDORACM" name="Collection" namespace="islandora:collection" pid="islandora:collectionCModel"/> |
||||
</content_models> |
||||
<search_terms> |
||||
<term field="dc.title">dc.title</term> |
||||
<term field="dc.creator">dc.creator</term> |
||||
<term default="true" field="dc.description">dc.description</term> |
||||
<term field="dc.date">dc.date</term> |
||||
<term field="dc.identifier">dc.identifier</term> |
||||
<term field="dc.language">dc.language</term> |
||||
<term field="dc.publisher">dc.publisher</term> |
||||
<term field="dc.rights">dc.rights</term> |
||||
<term field="dc.subject">dc.subject</term> |
||||
<term field="dc.relation">dc.relation</term> |
||||
<term field="dcterms.temporal">dcterms.temporal</term> |
||||
<term field="dcterms.spatial">dcterms.spatial</term> |
||||
<term field="fgs.DS.first.text">Full Text</term> |
||||
</search_terms> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
</collection_policy> |
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<collection_policy> |
||||
<!---we will define allowed mimetypes and what to do with various types as part of the content model--> |
||||
<contentmodels> |
||||
<contentmodel name="standard_flv"> |
||||
<pid_namespace>vre:test</pid_namespace> |
||||
<pid>vre:contentmodel</pid> |
||||
<dsid>STANDARD_FLV</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<search_terms> |
||||
<!--define what fields we can query as part of the advanced search for this collection--> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<collection_policy> |
||||
<!---we will define allowed mimetypes and what to do with various types as part of the content model--> |
||||
<contentmodels> |
||||
<contentmodel name="STANDARD_IMAGE"> |
||||
<pid_namespace>vre:spdf</pid_namespace> |
||||
<pid>vre:contentmodel</pid> |
||||
<dsid>STANDARD_IMAGE</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<!--if we define a query for an object the relationship we ask for may not be isMemberOfCollection. So when we ingest in th |
||||
Collection we will want the relationship to match the query. If this element is null we will use the isMemberOfCollection relationship--> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
<search_terms> |
||||
<!--define what fields we can query as part of the advanced search for this collection--> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> |
||||
<content_models> |
||||
<content_model name="STANDARD_JPEG" dsid="ISLANDORACM" namespace="demo:Smiley" pid="demo:DualResImage"/> |
||||
</content_models> |
||||
<search_terms> |
||||
<term field="dc.title">dc.title</term> |
||||
<term field="dc.creator">dc.creator</term> |
||||
<term field="dc.description" default="true">dc.description</term> |
||||
<term field="dc.date">dc.date</term> |
||||
<term field="dc.identifier">dc.identifier</term> |
||||
<term field="dc.language">dc.language</term> |
||||
<term field="dc.publisher">dc.publisher</term> |
||||
<term field="dc.rights">dc.rights</term> |
||||
<term field="dc.subject">dc.subject</term> |
||||
<term field="dc.relation">dc.relation</term> |
||||
<term field="dcterms.temporal">dcterms.temporal</term> |
||||
<term field="dcterms.spatial">dcterms.spatial</term> |
||||
<term field="fgs.DS.first.text">Full Text</term> |
||||
</search_terms> |
||||
<relationship>isMemberOf</relationship> |
||||
</collection_policy> |
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> |
||||
<content_models> |
||||
<content_model name="STANDARD_PDF" dsid="ISLANDORACM" namespace="islandora:spdf" pid="islandora:standard_pdf"/> |
||||
<content_model name="STRICT_PDF" dsid="ISLANDORACM" namespace="islandora:strictpdf" pid="islandora:strict_pdf"/> |
||||
<content_model name="REFWORKS_BATCH" dsid="ISLANDORACM" namespace="islandora:ref" pid="islandora:refworks_cm"/> |
||||
</content_models> |
||||
<search_terms> |
||||
<term field="dc.title">dc.title</term> |
||||
<term field="dc.creator">dc.creator</term> |
||||
<term field="dc.description" default="true">dc.description</term> |
||||
<term field="dc.date">dc.date</term> |
||||
<term field="dc.identifier">dc.identifier</term> |
||||
<term field="dc.language">dc.language</term> |
||||
<term field="dc.publisher">dc.publisher</term> |
||||
<term field="dc.rights">dc.rights</term> |
||||
<term field="dc.subject">dc.subject</term> |
||||
<term field="dc.relation">dc.relation</term> |
||||
<term field="dcterms.temporal">dcterms.temporal</term> |
||||
<term field="dcterms.spatial">dcterms.spatial</term> |
||||
<term field="fgs.DS.first.text">Full Text</term> |
||||
</search_terms> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
</collection_policy> |
@ -0,0 +1,80 @@
|
||||
|
||||
<collection_policy> |
||||
<!---we will define allowed mimetypes and what to do with various types as part of the content model--> |
||||
<contentmodels> |
||||
<contentmodel name="REFWORKS"> |
||||
<pid_namespace>ir:ref</pid_namespace> |
||||
<pid>vre:contentmodel</pid> |
||||
<dsid>REFWORKS</dsid> |
||||
</contentmodel> |
||||
<contentmodel name="STANDARD_PDF"> |
||||
<pid_namespace>ir:ref</pid_namespace> |
||||
<pid>vre:contentmodel</pid> |
||||
<dsid>STANDARD_PDF</dsid> |
||||
</contentmodel> |
||||
<contentmodel name="STANDARD_IMAGE"> |
||||
<pid_namespace>ir:image</pid_namespace> |
||||
<pid>vre:contentmodel</pid> |
||||
<dsid>STANDARD_IMAGE</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<!--if we define a query for an object the relationship we ask for may not be isMemberOfCollection. So when we ingest in th |
||||
Collection we will want the relationship to match the query. If this element is null we will use the isMemberOfCollection relationship--> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
<search_terms> |
||||
<!--define what fields we can query as part of the advanced search for this collection--> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,7 @@
|
||||
This folder holds sample collection policy xml files. |
||||
|
||||
These are not used by the module directly from this location but should |
||||
be added as datatreams to objects with a content model property of Collection or |
||||
Community. The datastream id should be COLLECTION_POLICY. |
||||
|
||||
PERSONAL-COLLECTION-POLCIY is referenced from code do not remove |
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<collection_policy> |
||||
<!---we will define allowed mimetypes and what to do with various types as part of the content model--> |
||||
<contentmodels> |
||||
<contentmodel name="REFWORKS"> |
||||
<pid_namespace>ir:ref</pid_namespace> |
||||
<pid>islandora:refworksCModel</pid> |
||||
<dsid>ISLANDORACM</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
</collection_policy> |
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<collection_policy> |
||||
<!---we will define allowed mimetypes and what to do with various types as part of the content model--> |
||||
<contentmodels> |
||||
<contentmodel name="STANDARD_PDF"> |
||||
<pid_namespace>vre:riri-</pid_namespace> |
||||
<pid>vre:contentmodel</pid> |
||||
<dsid>STANDARD_PDF</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<search_terms> |
||||
<!--define what fields we can query as part of the advanced search for this collection--> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,70 @@
|
||||
|
||||
<collection_policy> |
||||
<!---we will define allowed mimetypes and what to do with various types as part of the content model--> |
||||
<contentmodels> |
||||
<contentmodel name="Book"> |
||||
<pid_namespace>islandora</pid_namespace> |
||||
<pid>ilives:bookCModel</pid> |
||||
<dsid>ISLANDORACM</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<!--if we define a query for an object the relationship we ask for may not be isMemberOfCollection. So when we ingest in th |
||||
Collection we will want the relationship to match the query. If this element is null we will use the isMemberOfCollection relationship--> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
<search_terms> |
||||
<!--define what fields we can query as part of the advanced search for this collection--> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,84 @@
|
||||
<!-- |
||||
Document : slide_collection_policy.xml |
||||
Created on : January 12, 2010, 4:02 PM |
||||
Author : aoneill |
||||
Description: |
||||
Purpose of the document follows. |
||||
--> |
||||
<collection_policy> |
||||
<contentmodels> |
||||
<contentmodel name="SLIDE_CMODEL"> |
||||
<pid_namespace>islandora:slide</pid_namespace> |
||||
<pid>islandora:slideCModel</pid> |
||||
<dsid>ISLANDORACM</dsid> |
||||
</contentmodel> |
||||
<contentmodel name="MAP_CMODEL"> |
||||
<pid_namespace>islandora:map</pid_namespace> |
||||
<pid>islandora:mapCModel</pid> |
||||
<dsid>ISLANDORACM</dsid> |
||||
</contentmodel> |
||||
<contentmodel name="HERB_CMODEL"> |
||||
<pid_namespace>islandora:herb</pid_namespace> |
||||
<pid>islandora:herbCModel</pid> |
||||
<dsid>ISLANDORACM</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<!--if we define a query for an object the relationship we ask for may not be isMemberOfCollection. So when we ingest in th |
||||
Collection we will want the relationship to match the query.--> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
<search_terms> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> |
||||
<content_models> |
||||
<content_model name="Video" dsid="ISLANDORACM" namespace="islandora" pid="islandora:qtCModel"/> |
||||
</content_models> |
||||
<search_terms> |
||||
<term field="dc.title"> |
||||
dc.title |
||||
</term> |
||||
<term field="dc.creator"> |
||||
dc.creator |
||||
</term> |
||||
<term field="dc.description" default="true"> |
||||
dc.description |
||||
</term> |
||||
<term field="dc.date"> |
||||
dc.date |
||||
</term> |
||||
<term field="dc.identifier"> |
||||
dc.identifier |
||||
</term> |
||||
<term field="dc.language"> |
||||
dc.language |
||||
</term> |
||||
<term field="dc.publisher"> |
||||
dc.publisher |
||||
</term> |
||||
<term field="dc.rights"> |
||||
dc.rights |
||||
</term> |
||||
<term field="dc.subject"> |
||||
dc.subject |
||||
</term> |
||||
<term field="dc.relation"> |
||||
dc.relation |
||||
</term> |
||||
<term field="dcterms.temporal"> |
||||
dcterms.temporal |
||||
</term> |
||||
<term field="dcterms.spatial"> |
||||
dcterms.spatial |
||||
</term> |
||||
</search_terms> |
||||
<relationship> |
||||
isMemberOfCollection |
||||
</relationship> |
||||
</collection_policy> |
||||
|
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!-- |
||||
Document : slide_collection_policy.xml |
||||
Created on : January 12, 2010, 4:02 PM |
||||
Author : aoneill |
||||
Description: |
||||
Purpose of the document follows. |
||||
--> |
||||
<collection_policy> |
||||
<contentmodels> |
||||
<contentmodel name="SLIDE_CMODEL"> |
||||
<pid_namespace>islandora:slide</pid_namespace> |
||||
<pid>islandora:slideCModel</pid> |
||||
<dsid>ISLANDORACM</dsid> |
||||
</contentmodel> |
||||
</contentmodels> |
||||
<!--if we define a query for an object the relationship we ask for may not be isMemberOfCollection. So when we ingest in th |
||||
Collection we will want the relationship to match the query.--> |
||||
<relationship>isMemberOfCollection</relationship> |
||||
<search_terms> |
||||
<default>dc.description</default> |
||||
<term> |
||||
<field>dc.title</field> |
||||
<value>dc.title</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.creator</field> |
||||
<value>dc.creator</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.description</field> |
||||
<value>dc.description</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.date</field> |
||||
<value>dc.date</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.identifier</field> |
||||
<value>dc.identifier</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.language</field> |
||||
<value>dc.language</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.publisher</field> |
||||
<value>dc.publisher</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.rights</field> |
||||
<value>dc.rights</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.subject</field> |
||||
<value>dc.subject</value> |
||||
</term> |
||||
<term> |
||||
<field>dc.relation</field> |
||||
<value>dc.relation</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.temporal</field> |
||||
<value>dcterms.temporal</value> |
||||
</term> |
||||
<term> |
||||
<field>dcterms.spatial</field> |
||||
<value>dcterms.spatial</value> |
||||
</term> |
||||
<term> |
||||
<field>fgs.DS.first.text</field> |
||||
<value>Full Text</value> |
||||
</term> |
||||
</search_terms> |
||||
</collection_policy> |
@ -0,0 +1,48 @@
|
||||
|
||||
<xsd:schema xmlns="http://www.islandora.ca" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.islandora.ca" elementFormDefault="qualified" > |
||||
<xsd:annotation> |
||||
<xsd:documentation xml:lang="en"> |
||||
Islandora Collection Policy Schema |
||||
Islandora, Robertson Library, University of Prince Edward Island, 550 University Ave., Charlottetown, Prince Edward Island |
||||
</xsd:documentation> |
||||
</xsd:annotation> |
||||
|
||||
<xsd:element name="collection_policy" type="collection_policyType"/> |
||||
<xsd:complexType name="collection_policyType"> |
||||
<xsd:all> |
||||
<xsd:element name="content_models" type="content_modelsType"/> |
||||
<xsd:element name="search_terms" type="search_termsType"/> |
||||
<xsd:element name="relationship" type="xsd:string"/> |
||||
<xsd:element name="staging_area" type="xsd:string" minOccurs="0" maxOccurs="1"/> |
||||
</xsd:all> |
||||
<xsd:attribute name="name" type="xsd:normalizedString" use="required"/> |
||||
</xsd:complexType> |
||||
|
||||
<xsd:complexType name="content_modelsType"> |
||||
<xsd:sequence> |
||||
<xsd:element name="content_model" type="content_modelType" minOccurs="1" maxOccurs="unbounded"/> |
||||
</xsd:sequence> |
||||
</xsd:complexType> |
||||
|
||||
<xsd:complexType name="content_modelType"> |
||||
<xsd:attribute name="name" type="xsd:normalizedString" use="required"/> |
||||
<xsd:attribute name="dsid" type="xsd:normalizedString" use="required"/> |
||||
<xsd:attribute name="namespace" type="xsd:normalizedString" use="required"/> |
||||
<xsd:attribute name="pid" type="xsd:normalizedString" use="required"/> |
||||
</xsd:complexType> |
||||
|
||||
<xsd:complexType name="search_termsType"> |
||||
<xsd:sequence> |
||||
<xsd:element name="term" type="termType" minOccurs="0" maxOccurs="unbounded"/> |
||||
</xsd:sequence> |
||||
</xsd:complexType> |
||||
|
||||
<xsd:complexType name="termType"> |
||||
<xsd:simpleContent> |
||||
<xsd:extension base="xsd:string"> |
||||
<xsd:attribute name="field" type="xsd:string" use="optional"/> |
||||
<xsd:attribute name="default" type="xsd:boolean" default="false"/> |
||||
</xsd:extension> |
||||
</xsd:simpleContent> |
||||
</xsd:complexType> |
||||
</xsd:schema> |
@ -0,0 +1,264 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
<xsl:apply-templates select="s:sparql/s:results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="s:sparql/s:results"> |
||||
<xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::s:result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="s:result"> |
||||
<xsl:variable name='OBJECTURI' select="s:object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="s:title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="(content='Collection' or content='Community')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/ |
||||
<xsl:value-of select="s:title"/>/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
|
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<br clear="all" /> |
||||
|
||||
|
||||
<xsl:value-of select="$newTitle"/> |
||||
|
||||
<xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')"> |
||||
<br />-- |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:attribute> |
||||
DETAILS |
||||
</a>-- |
||||
</xsl:if> |
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,7 @@
|
||||
select $object $title from <#ri> |
||||
where ($object <dc:title> $title |
||||
and $object <fedora-model:hasModel> $content |
||||
and $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:demos> |
||||
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
||||
|
||||
order by $title |
@ -0,0 +1,82 @@
|
||||
|
||||
<xsl:stylesheet exclude-result-prefixes="php" version="1.0" xmlns:php="http://php.net/xsl" |
||||
xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
<xsl:template match="/"> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="collTitle" select="/s:sparql/s:results/s:result/s:collTitle"/> |
||||
<xsl:variable name="collDesc" select="/s:sparql/s:results/s:result/s:collDesc"/> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/animation/animation-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/element/element-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/container/container_core-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/menu/menu-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/button/button-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script type="text/javascript"> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$PATH"/> |
||||
<xsl:text>/collection_views/yui_coverflow/js/CoverFlow.js</xsl:text> |
||||
</xsl:attribute> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script type="text/javascript"> |
||||
<xsl:text> |
||||
|
||||
// YAHOO.util.Event.onDOMReady(function(){ |
||||
//$(document).ready(function(){ |
||||
window.onload = function(){ |
||||
var images = [ |
||||
</xsl:text> |
||||
<xsl:for-each select="/s:sparql/s:results/s:result"> |
||||
<xsl:variable name="OBJECTURI" select="s:object/@uri"/> |
||||
<xsl:variable name="pid" select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:text>{src: '</xsl:text> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/TN', label: '</xsl:text> |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
<xsl:text>', onclick: function(){alert('image1');}}, |
||||
</xsl:text> |
||||
</xsl:for-each> |
||||
<xsl:text> |
||||
]; |
||||
|
||||
var myCoverFlow = new YAHOO.ext.CoverFlow('coverFlowTest', {height: 200, width: 600, images: images}); |
||||
|
||||
function moveLeft(e, coverFlow){ |
||||
coverFlow.selectNext(); |
||||
} |
||||
function moveRight(e, coverFlow){ |
||||
coverFlow.selectPrevious(); |
||||
} |
||||
var myMoveLeftBtn = new YAHOO.widget.Button('moveLeftButton', {onclick: {fn: moveLeft, obj: myCoverFlow}}); |
||||
var myMoveRightBtn = new YAHOO.widget.Button('moveRightButton', {onclick: {fn: moveRight, obj: myCoverFlow}}); |
||||
|
||||
}; |
||||
</xsl:text> |
||||
</script> |
||||
<div class="title">Testing YUI's CoverFlow version 0.1 (beta)</div> |
||||
<div id="coverFlowTest"/> |
||||
<input id="moveLeftButton" type="button" value="Select Next"/> |
||||
<input id="moveRightButton" type="button" value="Select Previous"/> |
||||
<br/> |
||||
<br/> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,86 @@
|
||||
|
||||
<xsl:stylesheet exclude-result-prefixes="php" version="1.0" xmlns:php="http://php.net/xsl" |
||||
xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
<xsl:template match="/"> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="collTitle" select="/s:sparql/s:results/s:result/s:collTitle"/> |
||||
<xsl:variable name="collDesc" select="/s:sparql/s:results/s:result/s:collDesc"/> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/animation/animation-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/element/element-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/container/container_core-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/menu/menu-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script src="http://yui.yahooapis.com/2.7.0/build/button/button-min.js" type="text/javascript"> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script type="text/javascript"> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$PATH"/> |
||||
<xsl:text>/collection_views/yui_coverflow/js/CoverFlow.js</xsl:text> |
||||
</xsl:attribute> |
||||
<xsl:comment>Comment added so script is recognised</xsl:comment> |
||||
</script> |
||||
<script type="text/javascript"> |
||||
<xsl:text> |
||||
|
||||
// YAHOO.util.Event.onDOMReady(function(){ |
||||
//$(document).ready(function(){ |
||||
window.onload = function(){ |
||||
var images = [ |
||||
</xsl:text> |
||||
<xsl:for-each select="/s:sparql/s:results/s:result"> |
||||
<xsl:variable name="OBJECTURI" select="s:object/@uri"/> |
||||
<xsl:variable name="pid" select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:text>{src: '</xsl:text> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/PRE', label: '</xsl:text> |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
<xsl:text>', onclick: function(){ window.location='</xsl:text> |
||||
<xsl:value-of select="$BASEURL" /> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>';}}, |
||||
</xsl:text> |
||||
</xsl:for-each> |
||||
<xsl:text> |
||||
]; |
||||
|
||||
var myCoverFlow = new YAHOO.ext.CoverFlow('coverFlowTest', {height: 300, width: 650, images: images}); |
||||
|
||||
function moveLeft(e, coverFlow){ |
||||
coverFlow.selectNext(); |
||||
} |
||||
function moveRight(e, coverFlow){ |
||||
coverFlow.selectPrevious(); |
||||
} |
||||
var myMoveLeftBtn = new YAHOO.widget.Button('moveLeftButton', {onclick: {fn: moveLeft, obj: myCoverFlow}}); |
||||
var myMoveRightBtn = new YAHOO.widget.Button('moveRightButton', {onclick: {fn: moveRight, obj: myCoverFlow}}); |
||||
|
||||
}; |
||||
</xsl:text> |
||||
</script> |
||||
<div class="title">Testing YUI's CoverFlow version 0.1 (beta)</div> |
||||
<div id="coverFlowTest"/> |
||||
<input id="moveLeftButton" type="button" value="Select Next"/> |
||||
<input id="moveRightButton" type="button" value="Select Previous"/> |
||||
<br/> |
||||
<br/> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,285 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3" width="90%"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
|
||||
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<a> |
||||
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each>- |
||||
--> |
||||
<xsl:apply-templates select="sparql/results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="sparql/results"> |
||||
<xsl:for-each select="result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="result"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="(content='Collection' or content='Community')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/OBJ/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
<xsl:attribute name="alt"> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</xsl:attribute> |
||||
</img> |
||||
</a> |
||||
<br clear="all" /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</a> |
||||
|
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,11 @@
|
||||
This folder holds xslt files that can be used to transform the |
||||
display of a collection. These files are not used by the module from |
||||
this location but should be added as datastreams to objects that have a |
||||
content model of Collection. |
||||
|
||||
The datastream id should be COLLECTION_VIEW |
||||
|
||||
NOTE: If you add a invalid xslt to a as a collection view you will |
||||
no longer have access to that object or collection. You may have to |
||||
fire up the fedora-admin utility and move or modify the Collection_View datastream. This |
||||
is a bug but not sure when it will be fixed. |
@ -0,0 +1,282 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3" width="90%"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
|
||||
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<a> |
||||
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each>- |
||||
--> |
||||
<xsl:apply-templates select="s:sparql/s:results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="s:sparql/s:results"> |
||||
<xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::s:result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="s:result"> |
||||
<xsl:variable name='OBJECTURI' select="s:object/@uri"/> |
||||
<xsl:variable name='CONTENTURI' select="s:content/@uri"/> |
||||
<xsl:variable name='CONTENTMODEL' select="substring-after($CONTENTURI,'/')"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="s:title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="($CONTENTMODEL='islandora:collectionCModel')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/OBJ/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
<xsl:value-of select="s:content"/> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
<!-- <a> |
||||
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> |
||||
</xsl:attribute> |
||||
<img> |
||||
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
<xsl:attribute name="alt"><xsl:value-of select="$newTitle"/> |
||||
</xsl:attribute> |
||||
</img> </a> <br clear="all" />--> |
||||
|
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</a> |
||||
|
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,288 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3" width="90%"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
|
||||
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<a> |
||||
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each>- |
||||
--> |
||||
<xsl:apply-templates select="s:sparql/s:results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="s:sparql/s:results"> |
||||
<xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::s:result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="s:result"> |
||||
<xsl:variable name='OBJECTURI' select="s:object/@uri"/> |
||||
<xsl:variable name='CONTENTURI' select="s:content/@uri"/> |
||||
<xsl:variable name='CONTENTMODEL' select="substring-after($CONTENTURI,'/')"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="s:title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="($CONTENTMODEL='islandora:collectionCModel')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/OBJ/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
<xsl:value-of select="s:content"/> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$linkUrl"/> |
||||
</xsl:attribute> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
<xsl:attribute name="alt"> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</xsl:attribute> |
||||
</img> |
||||
</a> |
||||
<br clear="all" /> |
||||
|
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</a> |
||||
|
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,69 @@
|
||||
|
||||
<xsl:stylesheet version="1.0" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
<xsl:template match="/"> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="collTitle" select="/s:sparql/s:results/s:result/s:collTitle"/> |
||||
<xsl:variable name="collDesc" select="/s:sparql/s:results/s:result/s:collDesc"/> |
||||
|
||||
<center> |
||||
<font face="arial,helvetica"> |
||||
<h2> |
||||
<xsl:value-of select="$collTitle"/> |
||||
<br/> |
||||
<i> |
||||
<xsl:value-of select="$collDesc"/> |
||||
</i> |
||||
</h2> |
||||
</font> |
||||
</center> |
||||
<hr size="1"/> |
||||
<center> |
||||
<table border="0" cellpadding="5"> |
||||
<xsl:for-each select="/s:sparql/s:results/s:result"> |
||||
<xsl:variable name="pid" select="substring-after(s:member/@uri, '/')"/> |
||||
<tr> |
||||
<td> |
||||
<center> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/FULL_SIZE</xsl:text> |
||||
</xsl:attribute> |
||||
<img height="120" width="160"> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/MEDIUM_SIZE</xsl:text> |
||||
</xsl:attribute> |
||||
</img> |
||||
<br/> |
||||
( Full Size ) |
||||
</a> |
||||
</center> |
||||
</td> |
||||
<td> |
||||
<b> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/>/-/ |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
</a> |
||||
</b> |
||||
<br/> |
||||
<xsl:value-of select="s:memberDesc"/> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</table> |
||||
</center> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,66 @@
|
||||
|
||||
<xsl:stylesheet version="1.0" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
<xsl:template match="/"> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="collTitle" select="/s:sparql/s:results/s:result/s:collTitle"/> |
||||
<xsl:variable name="collDesc" select="/s:sparql/s:results/s:result/s:collDesc"/> |
||||
|
||||
<center> |
||||
<font face="arial,helvetica"> |
||||
<h2> |
||||
<xsl:value-of select="$collTitle"/> |
||||
<br/> |
||||
<i> |
||||
<xsl:value-of select="$collDesc"/> |
||||
</i> |
||||
</h2> |
||||
</font> |
||||
</center> |
||||
<hr size="1"/> |
||||
<center> |
||||
<table border="0" cellpadding="5"> |
||||
<xsl:for-each select="/s:sparql/s:results/s:result"> |
||||
<xsl:variable name="pid" select="substring-after(s:member/@uri, '/')"/> |
||||
<tr> |
||||
<td> |
||||
<center> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
</xsl:attribute> |
||||
<img height="120" width="160"> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/THUMBNAIL</xsl:text> |
||||
</xsl:attribute> |
||||
</img> |
||||
</a> |
||||
</center> |
||||
</td> |
||||
<td> |
||||
<b> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/>/-/ |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
</a> |
||||
</b> |
||||
<br/> |
||||
<xsl:value-of select="s:memberDesc"/> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</table> |
||||
</center> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,6 @@
|
||||
select $object $title from <#ri> |
||||
where ($object <dc:title> $title |
||||
and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> |
||||
or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) |
||||
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
||||
order by $title |
@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- DEFAULT XSLT FOR COLLECTIONS THAT DO NOT DEFINE THEIR OWN--> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name='columns' select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
|
||||
<table> |
||||
<tr> |
||||
<td colspan="2"> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
</td> |
||||
<td> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</table> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> |
||||
<dc:title>Demo Image Collection</dc:title> |
||||
<dc:identifier>islandora:demo_image_collection</dc:identifier> |
||||
<dc:description>Demo image collection</dc:description> |
||||
</oai_dc:dc> |
@ -0,0 +1,30 @@
|
||||
|
||||
<xsl:stylesheet version="1.0" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
<!-- simple list view for a itql query that looks queries for $object and $title only --> |
||||
<xsl:template match="/"> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
|
||||
<ul> |
||||
<xsl:for-each select="/s:sparql/s:results/s:result"> |
||||
<xsl:variable name="pid" select="substring-after(s:object/@uri, '/')"/> |
||||
<li> |
||||
|
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/>/-/ |
||||
<xsl:value-of select="s:title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="s:title"/> |
||||
</a> |
||||
|
||||
|
||||
</li> |
||||
</xsl:for-each> |
||||
</ul> |
||||
|
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,7 @@
|
||||
select $collTitle $collDesc $member $memberTitle $memberDesc |
||||
from <#ri> |
||||
where %parent_collection% <dc:title> $collTitle |
||||
and %parent_collection% <dc:description> $collDesc |
||||
and $member <fedora-rels-ext:isMemberOf> %parent_collection% |
||||
and $member <dc:title> $memberTitle |
||||
and $member <dc:description> $memberDesc |
@ -0,0 +1,68 @@
|
||||
|
||||
<xsl:stylesheet version="1.0" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
<xsl:template match="/"> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="collTitle" select="/s:sparql/s:results/s:result/s:collTitle"/> |
||||
<xsl:variable name="collDesc" select="/s:sparql/s:results/s:result/s:collDesc"/> |
||||
<center> |
||||
<font face="arial,helvetica"> |
||||
<h2> |
||||
<xsl:value-of select="$collTitle"/> |
||||
<br/> |
||||
<i> |
||||
<xsl:value-of select="$collDesc"/> |
||||
</i> |
||||
</h2> |
||||
</font> |
||||
</center> |
||||
<hr size="1"/> |
||||
<center> |
||||
<table border="0" cellpadding="5"> |
||||
<xsl:for-each select="/s:sparql/s:results/s:result"> |
||||
<xsl:variable name="pid" select="substring-after(s:member/@uri, '/')"/> |
||||
<tr> |
||||
<td> |
||||
<center> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/FULL_SIZE</xsl:text> |
||||
</xsl:attribute> |
||||
<img height="120" width="160"> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/> |
||||
<xsl:text>/MEDIUM_SIZE</xsl:text> |
||||
</xsl:attribute> |
||||
</img> |
||||
<br/> |
||||
( Full Size ) |
||||
</a> |
||||
</center> |
||||
</td> |
||||
<td> |
||||
<b> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
<xsl:text>/fedora/repository/</xsl:text> |
||||
<xsl:value-of select="$pid"/>/-/ |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="s:memberTitle"/> |
||||
</a> |
||||
</b> |
||||
<br/> |
||||
<xsl:value-of select="s:memberDesc"/> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</table> |
||||
</center> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,18 @@
|
||||
body { |
||||
font-family: Arial; |
||||
font-size: 12px; |
||||
color: gray; |
||||
background: black; |
||||
} |
||||
|
||||
.title { |
||||
font-size: 18px; |
||||
font-weight: bold; |
||||
} |
||||
|
||||
#coverFlowTest .coverFlowLabel { |
||||
margin-top: 10px; |
||||
font-size: 14px; |
||||
color: #C0C0C0; |
||||
font-weight: bold; |
||||
} |
@ -0,0 +1,996 @@
|
||||
/** |
||||
* @author elmasse (Maximiliano Fierro) |
||||
* @version 0.1 beta |
||||
* |
||||
* @usage: |
||||
* <code>
|
||||
* var images = [ |
||||
* {src: 'images/ardillitaMac.jpg'}, |
||||
* {src: 'http://farm2.static.flickr.com/1380/1426855399_b4b8eccbdb.jpg?v=0'}, |
||||
* {src: 'http://farm1.static.flickr.com/69/213130158_0d1aa23576_d.jpg'} |
||||
* ]; |
||||
* var myCoverFlow = new YAHOO.ext.CoverFlow('coverFlowTest', {height: 200, width: 800, images: images, bgColor: '#C0C0C0'}); |
||||
* </code> |
||||
* |
||||
*/ |
||||
|
||||
|
||||
YAHOO.namespace("ext"); |
||||
|
||||
//(function(){
|
||||
|
||||
/** |
||||
* @class CoverFlow
|
||||
* @namespace YAHOO.ext |
||||
* @constructor |
||||
* @param el {String|HTMLElement} Reference to element where CoverFlow will be rendered. |
||||
* @param config {Object} configuration object |
||||
* config.height {Number} Element height. Optional. Default: CoverFlow.DEFAULT_HEIGHT. |
||||
* config.width {Number} Element width. Optional. Default: CoverFlow.DEFAULT_WIDTH. |
||||
* config.images {Array} Array of Images. [{src:}] |
||||
* config.bgColor {String} Background color. Could be in the form #00000 or black. Optional. Default: CoverFlow.DEFAULT_BG_COLOR.
|
||||
*
|
||||
*/ |
||||
YAHOO.ext.CoverFlow = function(el, userConfig){ |
||||
if(el) |
||||
this.init(el, userConfig || {}); |
||||
}; |
||||
|
||||
//shortcuts
|
||||
var CoverFlow = YAHOO.ext.CoverFlow;
|
||||
var Dom = YAHOO.util.Dom; |
||||
|
||||
|
||||
/** |
||||
* Defaults |
||||
*/ |
||||
CoverFlow.DEFAULT_HEIGHT = 300; |
||||
CoverFlow.DEFAULT_WIDTH = 800; |
||||
CoverFlow.DEFAULT_BG_COLOR = '#000000';
|
||||
CoverFlow.IMAGE_SEPARATION = 50; |
||||
CoverFlow.RIGHT = 'right'; |
||||
CoverFlow.LEFT = 'left'; |
||||
CoverFlow.LABEL_CLASS = 'coverFlowLabel'; |
||||
|
||||
CoverFlow.prototype = { |
||||
//Images array (it's a sort of transient var)
|
||||
images: [], |
||||
//Items array {CoverFlowItem[]}
|
||||
coverFlowItems: [], |
||||
|
||||
remainingImages: 9999, |
||||
|
||||
element: null, |
||||
labelElement: null, |
||||
containerHeight: 0, |
||||
containerWidth: 0, |
||||
|
||||
imageHeightRatio: 0.6, |
||||
imageWidthRatio: 0.2, |
||||
reflectionRatio: 0.6, // this causes: imageTotalHeightRatio = imageHeightRatio + imageHeightRatio*reflectionRatio
|
||||
topRatio: 0.1, |
||||
sideRatio: 0.4, |
||||
|
||||
perspectiveAngle: 20, |
||||
imageZIndex: 1000, |
||||
selectedImageZIndex: 9999, |
||||
selectedItem: 0, |
||||
|
||||
moveQueue: [], |
||||
animationWorking: false, |
||||
|
||||
init: function(el, userConfig){ |
||||
|
||||
this.element = Dom.get(el); |
||||
this.applyConfig(userConfig); |
||||
|
||||
if(userConfig.images) |
||||
this.addImages(userConfig.images); |
||||
|
||||
this.attachEventListeners(); |
||||
this.createLabelElement(); |
||||
}, |
||||
|
||||
applyConfig: function(config){ |
||||
this.containerHeight = config.height || CoverFlow.DEFAULT_HEIGHT; |
||||
this.containerWidth = config.width || CoverFlow.DEFAULT_WIDTH; |
||||
this.backgroundColor = config.bgColor || CoverFlow.DEFAULT_BG_COLOR; |
||||
|
||||
this.element.style.position = 'relative'; |
||||
this.element.style.height = this.containerHeight + 'px'; |
||||
this.element.style.width = this.containerWidth + 'px'; |
||||
this.element.style.background = this.backgroundColor; |
||||
this.element.style.overflow = 'hidden'; |
||||
}, |
||||
|
||||
addImages: function(images){ |
||||
this.images = []; |
||||
this.remainingImages = images.length; |
||||
|
||||
for(var i=0; i < images.length; i++){ |
||||
var img = images[i]; |
||||
var image = new Image(); |
||||
image.id = Dom.generateId(); |
||||
image.index = i; |
||||
image.onclick = img.onclick; |
||||
image.label = img.label; |
||||
|
||||
//hide images
|
||||
image.style.visibility = 'hidden'; |
||||
image.style.display = 'none'; |
||||
//this is to maintain image order since image.onload will be called randomly
|
||||
this.element.appendChild(image); |
||||
//a shortcut to not create another context to call onload
|
||||
var me = this; |
||||
// image.onload = function(){
|
||||
// CoverFlow.preloadImage(me, this); // this = image
|
||||
// };
|
||||
YAHOO.util.Event.on(image, 'load', this.preloadImage, image, this); |
||||
image.src = img.src; |
||||
|
||||
}; |
||||
|
||||
}, |
||||
|
||||
/** |
||||
* @function preloadImage |
||||
* @param event |
||||
* @param image |
||||
* @return void |
||||
*/ |
||||
preloadImage : function(e, image){ |
||||
this.images.push(image); |
||||
this.checkAllImagesLoaded(); |
||||
}, |
||||
|
||||
checkAllImagesLoaded: function(){ |
||||
this.remainingImages--; |
||||
if(!this.remainingImages){ |
||||
this.setup(); |
||||
} |
||||
}, |
||||
|
||||
setup: function(){ |
||||
this.createCoverFlowItems(); |
||||
this.sortCoverFlowItems(); |
||||
this.initCoverFlow(); |
||||
}, |
||||
|
||||
initCoverFlow: function(){ |
||||
|
||||
for(var i=0; i < this.coverFlowItems.length; i++){ |
||||
var coverFlowItem = this.coverFlowItems[i]; |
||||
|
||||
var angle = 0; |
||||
var direction; |
||||
|
||||
if(i==0){ |
||||
coverFlowItem.setZIndex(this.selectedImageZIndex); |
||||
coverFlowItem.setLeft(this.getCenter() - coverFlowItem.element.width/2); |
||||
coverFlowItem.isSelected(true); |
||||
this.selectedItem = 0; |
||||
this.showLabel(coverFlowItem.getLabel()); |
||||
}else{ |
||||
angle = this.perspectiveAngle; |
||||
direction = CoverFlow.LEFT; |
||||
coverFlowItem.setZIndex(this.imageZIndex - i); |
||||
coverFlowItem.setLeft( this.getRightStart()+ (i - 1)* CoverFlow.IMAGE_SEPARATION); |
||||
coverFlowItem.isSelected(false); |
||||
} |
||||
coverFlowItem.setAngle(angle); |
||||
coverFlowItem.drawInPerspective(direction); |
||||
} |
||||
}, |
||||
|
||||
createLabelElement: function(){ |
||||
var label = document.createElement('div'); |
||||
label.id = Dom.generateId(); |
||||
label.style.position = 'absolute'; |
||||
label.style.top = this.getFooterOffset() + 'px'; |
||||
label.innerHTML = ' '; |
||||
label.style.textAlign = 'center'; |
||||
label.style.width = this.containerWidth + 'px'; |
||||
label.style.zIndex = this.selectedImageZIndex + 10; |
||||
label.className = CoverFlow.LABEL_CLASS; |
||||
this.labelElement = this.element.appendChild(label); |
||||
}, |
||||
|
||||
showLabel: function(text){ |
||||
if(text) |
||||
this.labelElement.innerHTML = text; |
||||
else |
||||
this.labelElement.innerHTML = ''; |
||||
}, |
||||
|
||||
attachEventListeners: function(){ |
||||
new YAHOO.util.KeyListener(this.element, { |
||||
keys:39 |
||||
}, |
||||
{ |
||||
fn:this.selectNext, |
||||
scope:this, |
||||
correctScope:true |
||||
} ).enable(); |
||||
|
||||
new YAHOO.util.KeyListener(this.element, { |
||||
keys:37 |
||||
}, |
||||
{ |
||||
fn:this.selectPrevious, |
||||
scope:this, |
||||
correctScope:true |
||||
} ).enable(); |
||||
|
||||
|
||||
}, |
||||
|
||||
select: function(e,coverFlowItem){ |
||||
var distance = this.selectedItem - coverFlowItem.index; |
||||
if(distance < 0){ |
||||
for(var i=0; i < -distance; i++) |
||||
this.selectNext(); |
||||
}else{ |
||||
for(var i=0; i < distance; i++) |
||||
this.selectPrevious(); |
||||
} |
||||
}, |
||||
|
||||
|
||||
selectNext: function(){ |
||||
if(this.animationWorking){ |
||||
this.moveQueue.push('moveLeft'); |
||||
return; |
||||
} |
||||
|
||||
var animateItems = []; |
||||
|
||||
for(var i=0; i < this.coverFlowItems.length; i++){ |
||||
var coverFlowItem = this.coverFlowItems[i]; |
||||
var isLast = (this.selectedItem == this.coverFlowItems.length -1); |
||||
if(!isLast){ |
||||
var distance = i-this.selectedItem; |
||||
|
||||
if(distance == 0){// selected
|
||||
coverFlowItem.setZIndex(this.imageZIndex); |
||||
coverFlowItem.isSelected(false); |
||||
animateItems.push({ |
||||
item: coverFlowItem, |
||||
attribute:{ |
||||
angle: { |
||||
start: 0, |
||||
end: this.perspectiveAngle |
||||
} |
||||
} |
||||
}); |
||||
|
||||
coverFlowItem = this.coverFlowItems[++i]; |
||||
coverFlowItem.isSelected(true); |
||||
this.showLabel(coverFlowItem.getLabel()); |
||||
animateItems.push({ |
||||
item: coverFlowItem, |
||||
attribute:{ |
||||
angle: { |
||||
start: this.perspectiveAngle, |
||||
end: 0 |
||||
} |
||||
} |
||||
}); |
||||
|
||||
}else{ |
||||
animateItems.push({ |
||||
item: coverFlowItem, |
||||
attribute: { |
||||
left: { |
||||
start:coverFlowItem.getLeft(), |
||||
end: coverFlowItem.getLeft() - CoverFlow.IMAGE_SEPARATION |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
var animation = new CoverFlowAnimation({ |
||||
direction: CoverFlow.LEFT, |
||||
center: this.getCenter(), |
||||
startLeftPos: this.getLeftStart(), |
||||
startRightPos: this.getRightStart() |
||||
},
|
||||
animateItems, 0.5); |
||||
|
||||
animation.onStart.subscribe(this.handleAnimationWorking, this); |
||||
animation.onComplete.subscribe(this.handleQueuedMove, this); |
||||
|
||||
animation.animate(); |
||||
|
||||
if(this.selectedItem + 1 < this.coverFlowItems.length) |
||||
this.selectedItem++; |
||||
}, |
||||
|
||||
selectPrevious: function(){ |
||||
if(this.animationWorking){ |
||||
this.moveQueue.push('moveRight'); |
||||
return; |
||||
} |
||||
|
||||
var animateItems = []; |
||||
|
||||
for(var i=0; i < this.coverFlowItems.length; i++){ |
||||
var coverFlowItem = this.coverFlowItems[i]; |
||||
var isFirst = (this.selectedItem == 0); |
||||
var distance = i-this.selectedItem; |
||||
if(!isFirst){ |
||||
if(distance == - 1){ |
||||
coverFlowItem.setZIndex(this.selectedImageZIndex); |
||||
coverFlowItem.isSelected(true); |
||||
this.showLabel(coverFlowItem.getLabel()); |
||||
animateItems.push({ |
||||
item: coverFlowItem, |
||||
attribute: { |
||||
angle: { |
||||
start: this.perspectiveAngle, |
||||
end: 0 |
||||
} |
||||
} |
||||
}); |
||||
|
||||
coverFlowItem = this.coverFlowItems[++i]; |
||||
coverFlowItem.isSelected(false); |
||||
coverFlowItem.setZIndex(this.imageZIndex); |
||||
animateItems.push({ |
||||
item: coverFlowItem, |
||||
attribute: { |
||||
angle: { |
||||
start: 0, |
||||
end: this.perspectiveAngle |
||||
} |
||||
} |
||||
}); |
||||
}else{ |
||||
coverFlowItem.setZIndex(coverFlowItem.getZIndex() - 1); |
||||
animateItems.push({ |
||||
item: coverFlowItem, |
||||
attribute: { |
||||
left: { |
||||
start:coverFlowItem.getLeft(), |
||||
end: coverFlowItem.getLeft() + CoverFlow.IMAGE_SEPARATION |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
var animation = new CoverFlowAnimation({ |
||||
direction: CoverFlow.RIGHT, |
||||
center: this.getCenter(), |
||||
startLeftPos: this.getLeftStart(), |
||||
startRightPos: this.getRightStart() |
||||
},
|
||||
animateItems, 0.5); |
||||
|
||||
animation.onStart.subscribe(this.handleAnimationWorking, this); |
||||
animation.onComplete.subscribe(this.handleQueuedMove, this); |
||||
|
||||
animation.animate(); |
||||
|
||||
if(this.selectedItem > 0) |
||||
this.selectedItem--; |
||||
}, |
||||
|
||||
handleAnimationWorking: function(a, b, cf){ |
||||
cf.animationWorking = true; |
||||
}, |
||||
|
||||
handleQueuedMove: function(msg, data, cf){ |
||||
cf.animationWorking = false; |
||||
|
||||
var next = cf.moveQueue.pop(); |
||||
if(next == 'moveLeft') |
||||
cf.selectNext(); |
||||
if(next == 'moveRight') |
||||
cf.selectPrevious(); |
||||
}, |
||||
|
||||
getCenter: function(){ |
||||
return this.containerWidth / 2; |
||||
}, |
||||
|
||||
getRightStart: function() { |
||||
return this.containerWidth - this.sideRatio * this.containerWidth; |
||||
}, |
||||
|
||||
getLeftStart: function() { |
||||
return this.sideRatio * this.containerWidth; |
||||
}, |
||||
|
||||
sortCoverFlowItems: function(){ |
||||
function sortFunction(aCoverFlowItem, bCoverFlowItem){ |
||||
return aCoverFlowItem.index - bCoverFlowItem.index; |
||||
} |
||||
|
||||
this.coverFlowItems.sort(sortFunction); |
||||
}, |
||||
|
||||
createCoverFlowItems: function(){ |
||||
this.coverFlowItems = []; |
||||
for(var i=0; i<this.images.length; i++){ |
||||
var image = this.images[i]; |
||||
var coverFlowItem = new CoverFlowItem(image, { |
||||
scaledWidth: this.scaleWidth(image), |
||||
scaledHeight: this.scaleHeight(image), |
||||
reflectionRatio: this.reflectionRatio, |
||||
bgColor: this.backgroundColor, |
||||
onclick: { |
||||
fn: this.select, |
||||
scope: this |
||||
} |
||||
}); |
||||
this.alignCenterHeight(coverFlowItem); |
||||
this.coverFlowItems.push(coverFlowItem); |
||||
}; |
||||
delete this.images; |
||||
}, |
||||
|
||||
alignCenterHeight: function(coverFlowItem){//review!!!!!
|
||||
coverFlowItem.element.style.position = 'absolute'; |
||||
|
||||
var imageHeight = coverFlowItem.canvas.height / (1 + this.reflectionRatio); |
||||
var top = this.getMaxImageHeight() - imageHeight; |
||||
top += this.topRatio * this.containerHeight; |
||||
|
||||
coverFlowItem.setTop(top); |
||||
|
||||
}, |
||||
|
||||
scaleHeight: function(image){ |
||||
var height = 0; |
||||
if(image.height <= this.getMaxImageHeight() && image.width <= this.getMaxImageWidth()){ |
||||
height = image.height; |
||||
} |
||||
if(image.height > this.getMaxImageHeight() && image.width <= this.getMaxImageWidth()){ |
||||
height = ((image.height / this.getMaxImageHeight())) * image.height; |
||||
} |
||||
if(image.height <= this.getMaxImageHeight() && image.width > this.getMaxImageWidth()){ |
||||
height = ((image.width / this.getMaxImageWidth())) * image.height; |
||||
} |
||||
if(image.height > this.getMaxImageHeight() && image.width > this.getMaxImageWidth()){ |
||||
if(image.height > image.width) |
||||
height = ((this.getMaxImageHeight() / image.height)) * image.height; |
||||
else |
||||
height = ((this.getMaxImageWidth() / image.width)) * image.height; |
||||
} |
||||
return height; |
||||
}, |
||||
|
||||
scaleWidth: function(image){ |
||||
var width = 0; |
||||
if(image.height <= this.getMaxImageHeight() && image.width <= this.getMaxImageWidth()){ |
||||
width = image.width; |
||||
} |
||||
if(image.height > this.getMaxImageHeight() && image.width <= this.getMaxImageWidth()){ |
||||
width = ((image.height / this.getMaxImageHeight())) * image.width; |
||||
} |
||||
if(image.height <= this.getMaxImageHeight() && image.width > this.getMaxImageWidth()){ |
||||
width = ((image.width / this.getMaxImageWidth())) * image.width; |
||||
} |
||||
if(image.height > this.getMaxImageHeight() && image.width > this.getMaxImageWidth()){ |
||||
if(image.height > image.width) |
||||
width = ((this.getMaxImageHeight() / image.height)) * image.width; |
||||
else |
||||
width = ((this.getMaxImageWidth() / image.width)) * image.width; |
||||
} |
||||
return width; |
||||
}, |
||||
|
||||
|
||||
getMaxImageHeight: function(){ |
||||
return (this.containerHeight * this.imageHeightRatio); |
||||
}, |
||||
|
||||
getMaxImageWidth: function(){ |
||||
return (this.containerWidth * this.imageWidthRatio); |
||||
}, |
||||
|
||||
getTopOffset: function(){ |
||||
return this.containerHeight * this.topRatio; |
||||
}, |
||||
|
||||
getFooterOffset: function(){ |
||||
return this.containerHeight * (this.topRatio + this.imageHeightRatio); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* @class CoverFlowItem
|
||||
*
|
||||
*/ |
||||
CoverFlowItem = function(image, config){ |
||||
if(image) |
||||
this.init(image, config); |
||||
}; |
||||
|
||||
CoverFlowItem.prototype = { |
||||
canvas: null, |
||||
element: null, |
||||
index: null, |
||||
id: null, |
||||
angle: 0, |
||||
selected: false, |
||||
onclickFn: null, |
||||
selectedOnclickFn: null, |
||||
label: null, |
||||
|
||||
onSelected: null, |
||||
|
||||
init: function(image, config){ |
||||
var scaledWidth = config.scaledWidth; |
||||
var scaledHeight = config.scaledHeight; |
||||
var reflectionRatio = config.reflectionRatio; |
||||
var bgColor = config.bgColor; |
||||
|
||||
this.id = image.id; |
||||
this.index = image.index; |
||||
this.onclickFn = config.onclick; |
||||
this.selectedOnclickFn = image.onclick; |
||||
this.label = image.label; |
||||
var parent = image.parentNode; |
||||
this.canvas = this.createImageCanvas(image,scaledWidth,scaledHeight,reflectionRatio, bgColor); |
||||
this.element = this.canvas.cloneNode(false); |
||||
this.element.id = this.id; |
||||
parent.replaceChild(this.element, image); |
||||
|
||||
this.onSelected = new YAHOO.util.CustomEvent('onSelected', this); |
||||
this.onSelected.subscribe(this.handleOnclick); |
||||
|
||||
}, |
||||
|
||||
getLabel: function(){ |
||||
return this.label; |
||||
}, |
||||
|
||||
handleOnclick: function(){ |
||||
YAHOO.util.Event.removeListener(this.element, 'click'); |
||||
if(!this.selected){ |
||||
YAHOO.util.Event.addListener(this.element, 'click', this.onclickFn.fn, this, this.onclickFn.scope); |
||||
}else{ |
||||
if(this.selectedOnclickFn && this.selectedOnclickFn.fn) |
||||
YAHOO.util.Event.addListener(this.element, 'click', this.selectedOnclickFn.fn, this, this.selectedOnclickFn.scope); |
||||
else |
||||
YAHOO.util.Event.addListener(this.element, 'click', this.selectedOnclickFn); |
||||
} |
||||
}, |
||||
|
||||
isSelected: function(selected){ |
||||
this.selected = selected; |
||||
this.onSelected.fire(); |
||||
}, |
||||
|
||||
setAngle: function(angle){ |
||||
this.angle = angle; |
||||
}, |
||||
|
||||
getAngle: function(){ |
||||
return this.angle; |
||||
}, |
||||
|
||||
setTop: function(top){ |
||||
this.element.style.top = top + 'px'; |
||||
}, |
||||
|
||||
setLeft: function(left){ |
||||
this.element.style.left = left + 'px'; |
||||
}, |
||||
|
||||
getLeft: function(){ |
||||
var ret = this.element.style.left; |
||||
return new Number(ret.replace("px", "")); |
||||
}, |
||||
|
||||
getZIndex: function(){ |
||||
return this.element.style.zIndex; |
||||
}, |
||||
|
||||
setZIndex: function(zIndex){ |
||||
this.element.style.zIndex = zIndex; |
||||
}, |
||||
|
||||
createImageCanvas: function(image, sWidth, sHeight, reflectionRatio, bgColor){ |
||||
|
||||
var imageCanvas = document.createElement('canvas'); |
||||
|
||||
if(imageCanvas.getContext){ |
||||
|
||||
var scaledWidth = sWidth; |
||||
var scaledHeight = sHeight; |
||||
var reflectionHeight = scaledHeight * reflectionRatio; |
||||
|
||||
imageCanvas.height = scaledHeight + reflectionHeight; |
||||
imageCanvas.width = scaledWidth; |
||||
|
||||
var ctx = imageCanvas.getContext('2d'); |
||||
|
||||
ctx.clearRect(0, 0, imageCanvas.width, imageCanvas.height); |
||||
ctx.globalCompositeOperation = 'source-over'; |
||||
ctx.fillStyle = 'rgba(0, 0, 0, 1)'; |
||||
ctx.fillRect(0, 0, imageCanvas.width, imageCanvas.height); |
||||
|
||||
//draw the reflection image
|
||||
ctx.save(); |
||||
ctx.translate(0, (2*scaledHeight)); |
||||
ctx.scale(1, -1); |
||||
ctx.drawImage(image, 0, 0, scaledWidth, scaledHeight); |
||||
ctx.restore(); |
||||
//create the gradient effect
|
||||
ctx.save(); |
||||
ctx.translate(0, scaledHeight); |
||||
ctx.globalCompositeOperation = 'destination-out'; |
||||
var grad = ctx.createLinearGradient( 0, 0, 0, scaledHeight); |
||||
grad.addColorStop(1, 'rgba(0, 0, 0, 1)'); |
||||
grad.addColorStop(0, 'rgba(0, 0, 0, 0.75)'); |
||||
ctx.fillStyle = grad; |
||||
ctx.fillRect(0, 0, scaledWidth, scaledHeight); |
||||
//apply the background color to the gradient
|
||||
ctx.globalCompositeOperation = 'destination-over'; |
||||
ctx.fillStyle = bgColor; |
||||
'#000'; |
||||
ctx.globalAlpha = 0.8; |
||||
ctx.fillRect(0, 0 , scaledWidth, scaledHeight); |
||||
ctx.restore(); |
||||
//draw the image
|
||||
ctx.save(); |
||||
ctx.translate(0, 0); |
||||
ctx.globalCompositeOperation = 'source-over'; |
||||
ctx.drawImage(image, 0, 0, scaledWidth, scaledHeight); |
||||
ctx.restore(); |
||||
|
||||
return imageCanvas; |
||||
} |
||||
}, |
||||
|
||||
drawInPerspective: function(direction, frameSize){ |
||||
var canvas = this.element; |
||||
var image = this.canvas; |
||||
var angle = Math.ceil(this.angle); |
||||
var ctx; |
||||
var originalWidth = image.width; |
||||
var originalHeight = image.height; |
||||
var destinationWidth = destinationWidth || originalWidth; // for future use
|
||||
var destinationHeight = destinationHeight || originalHeight; // for future use
|
||||
|
||||
var perspectiveCanvas = document.createElement('canvas'); |
||||
perspectiveCanvas.height = destinationHeight; |
||||
perspectiveCanvas.width = destinationWidth; |
||||
var perspectiveCtx = perspectiveCanvas.getContext('2d'); |
||||
|
||||
var alpha = angle * Math.PI/180; // Math uses radian
|
||||
|
||||
if(alpha > 0){ // if we have an angle greater than 0 then apply the perspective
|
||||
var right = (direction == CoverFlow.RIGHT); |
||||
|
||||
var initialX=0, finalX=0, initialY=0, finalY=0; |
||||
|
||||
frameSize = frameSize || 1; |
||||
var xDes, yDes; |
||||
var heightDes, widthDes; |
||||
var perspectiveWidht = destinationWidth; |
||||
|
||||
var frameFactor = frameSize / originalWidth; |
||||
var frames = Math.floor(originalWidth / frameSize); |
||||
|
||||
var widthSrc = frameSize ; |
||||
var heightSrc = originalHeight; |
||||
|
||||
for(var i=0; i < frames; i++){ |
||||
var xSrc = (i) * frameSize; |
||||
var ySrc = 0; |
||||
var betaTan = 0; |
||||
width = destinationWidth * (i) * frameFactor; |
||||
horizon = destinationHeight / 2; |
||||
|
||||
if(right){ |
||||
betaTan = horizon/((Math.tan(alpha)*horizon) + width); |
||||
xDes = (betaTan*width)/(Math.tan(alpha) + betaTan); |
||||
yDes = Math.tan(alpha) * xDes; |
||||
|
||||
if(i == frames -1){ |
||||
finalX=xDes; |
||||
finalY=yDes; |
||||
} |
||||
}else{ |
||||
betaTan = horizon/((Math.tan(alpha)*horizon) +(destinationWidth-width)); |
||||
xDes = (Math.tan(alpha)*(destinationWidth) + (betaTan * width))/(Math.tan(alpha) + betaTan); |
||||
yDes = -Math.tan(alpha)*xDes + (Math.tan(alpha)*(destinationWidth)); |
||||
|
||||
if(i == 0){ |
||||
initialX = xDes; |
||||
initialY = yDes; |
||||
finalX = destinationWidth; |
||||
finalY = 0; |
||||
} |
||||
} |
||||
|
||||
heightDes = destinationHeight - (2*yDes); |
||||
widthDes = heightDes / destinationHeight * destinationWidth; |
||||
|
||||
perspectiveCtx.drawImage(image, xSrc, ySrc, widthSrc, heightSrc, xDes, yDes, widthDes, heightDes); |
||||
|
||||
} |
||||
|
||||
perspectiveWidth = finalX - initialX; |
||||
originalCanvasWidth = destinationWidth; |
||||
canvas.width = perspectiveWidth; |
||||
|
||||
ctx = canvas.getContext('2d'); |
||||
|
||||
//remove exceeded pixels
|
||||
ctx.beginPath(); |
||||
if(right){ |
||||
ctx.moveTo(0, 0); |
||||
ctx.lineTo(finalX, finalY); |
||||
ctx.lineTo(finalX, finalY + (destinationHeight - 2*finalY)); |
||||
ctx.lineTo(0, destinationHeight); |
||||
ctx.lineTo(0,0); |
||||
}else{ |
||||
var initialX1 = initialX - (originalCanvasWidth - perspectiveWidth); |
||||
var finalX1 = finalX - (originalCanvasWidth - perspectiveWidth); |
||||
ctx.moveTo(0, initialY); |
||||
ctx.lineTo(finalX1, finalY); |
||||
ctx.lineTo(finalX1, destinationHeight); |
||||
ctx.lineTo(initialX1, initialY + (destinationHeight - 2*initialY)); |
||||
ctx.lineTo(0, initialY); |
||||
} |
||||
ctx.closePath(); |
||||
ctx.clip(); |
||||
|
||||
ctx.drawImage(perspectiveCanvas, initialX, 0, perspectiveWidth, destinationHeight, 0, 0, perspectiveWidth, destinationHeight); |
||||
|
||||
}else{ |
||||
|
||||
canvas.width = perspectiveCanvas.width; |
||||
canvas.height = perspectiveCanvas.height; |
||||
perspectiveCtx.drawImage(image, 0, 0, originalWidth, originalHeight, 0, 0, destinationWidth, destinationHeight); |
||||
ctx = canvas.getContext('2d'); |
||||
ctx.clearRect(0, 0, canvas.width, canvas.height); |
||||
ctx.drawImage(perspectiveCanvas, 0, 0); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
|
||||
/** |
||||
* @class CoverFlowAnimation |
||||
* @requires YAHOO.util.AnimMgr |
||||
*/ |
||||
CoverFlowAnimation = function(config, animationItems, duration){ |
||||
this.init(config, animationItems, duration); |
||||
};
|
||||
|
||||
CoverFlowAnimation.prototype = { |
||||
direction: null, |
||||
|
||||
center: null, |
||||
|
||||
startLeftPos: null, |
||||
|
||||
startRightPos: null, |
||||
|
||||
animationItems: null, |
||||
|
||||
method : YAHOO.util.Easing.easeNone, |
||||
|
||||
animated: false, |
||||
|
||||
startTime: null, |
||||
|
||||
actualFrames : 0, |
||||
|
||||
useSeconds : true, // default to seconds
|
||||
|
||||
currentFrame : 0, |
||||
|
||||
totalFrames : YAHOO.util.AnimMgr.fps, |
||||
|
||||
init: function(config, animationItems, duration){ |
||||
this.direction = config.direction; |
||||
this.center = config.center; |
||||
this.startLeftPos = config.startLeftPos; |
||||
this.startRightPos = config.startRightPos; |
||||
this.animationItems = animationItems; |
||||
this.duration = duration || 1; |
||||
this.registerEvents(); |
||||
}, |
||||
|
||||
registerEvents: function(){ |
||||
/** |
||||
* Custom event that fires after onStart, useful in subclassing |
||||
* @private |
||||
*/ |
||||
this._onStart = new YAHOO.util.CustomEvent('_start', this, true); |
||||
|
||||
/** |
||||
* Custom event that fires when animation begins |
||||
* Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction) |
||||
* @event onStart |
||||
*/ |
||||
this.onStart = new YAHOO.util.CustomEvent('start', this); |
||||
|
||||
/** |
||||
* Custom event that fires between each frame |
||||
* Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction) |
||||
* @event onTween |
||||
*/ |
||||
this.onTween = new YAHOO.util.CustomEvent('tween', this); |
||||
|
||||
/** |
||||
* Custom event that fires after onTween |
||||
* @private |
||||
*/ |
||||
this._onTween = new YAHOO.util.CustomEvent('_tween', this, true); |
||||
|
||||
/** |
||||
* Custom event that fires when animation ends |
||||
* Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction) |
||||
* @event onComplete |
||||
*/ |
||||
this.onComplete = new YAHOO.util.CustomEvent('complete', this); |
||||
/** |
||||
* Custom event that fires after onComplete |
||||
* @private |
||||
*/ |
||||
this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true); |
||||
|
||||
this._onStart.subscribe(this.doOnStart); |
||||
this._onTween.subscribe(this.doOnTween); |
||||
this._onComplete.subscribe(this.doOnComplete); |
||||
|
||||
}, |
||||
|
||||
isAnimated : function() { |
||||
return this.animated; |
||||
}, |
||||
|
||||
getStartTime : function() { |
||||
return this.startTime; |
||||
}, |
||||
|
||||
doMethod: function(start, end) { |
||||
return this.method(this.currentFrame, start, end - start, this.totalFrames); |
||||
}, |
||||
|
||||
animate : function() { |
||||
if ( this.isAnimated() ) { |
||||
return false; |
||||
} |
||||
|
||||
this.currentFrame = 0; |
||||
|
||||
this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration; |
||||
|
||||
if (this.duration === 0 && this.useSeconds) { // jump to last frame if zero second duration
|
||||
this.totalFrames = 1; |
||||
} |
||||
YAHOO.util.AnimMgr.registerElement(this); |
||||
return true; |
||||
}, |
||||
|
||||
stop : function(finish) { |
||||
if (!this.isAnimated()) { // nothing to stop
|
||||
return false; |
||||
} |
||||
|
||||
if (finish) { |
||||
this.currentFrame = this.totalFrames; |
||||
this._onTween.fire(); |
||||
} |
||||
YAHOO.util.AnimMgr.stop(this); |
||||
}, |
||||
|
||||
doOnStart : function() { |
||||
this.onStart.fire(); |
||||
|
||||
this.runtimeItems = []; |
||||
for (var i=0; i<this.animationItems.length; i++) { |
||||
this.setRuntimeItem(this.animationItems[i]); |
||||
} |
||||
|
||||
this.animated = true; |
||||
this.actualFrames = 0; |
||||
this.startTime = new Date(); |
||||
}, |
||||
|
||||
doOnTween : function() { |
||||
var data = { |
||||
duration: new Date() - this.getStartTime(), |
||||
currentFrame: this.currentFrame |
||||
}; |
||||
|
||||
data.toString = function() { |
||||
return ( |
||||
'duration: ' + data.duration + |
||||
', currentFrame: ' + data.currentFrame |
||||
); |
||||
}; |
||||
|
||||
this.onTween.fire(data); |
||||
|
||||
this.actualFrames += 1; |
||||
|
||||
var runtimeItems = this.runtimeItems; |
||||
|
||||
for (var i=0; i < runtimeItems.length; i++) { |
||||
this.setItemAttributes(runtimeItems[i]); |
||||
} |
||||
|
||||
}, |
||||
|
||||
doOnComplete : function() { |
||||
var actual_duration = (new Date() - this.getStartTime()) / 1000 ; |
||||
|
||||
var data = { |
||||
duration: actual_duration, |
||||
frames: this.actualFrames, |
||||
fps: this.actualFrames / actual_duration |
||||
}; |
||||
|
||||
data.toString = function() { |
||||
return ( |
||||
'duration: ' + data.duration + |
||||
', frames: ' + data.frames + |
||||
', fps: ' + data.fps |
||||
); |
||||
}; |
||||
|
||||
this.animated = false; |
||||
this.actualFrames = 0; |
||||
this.onComplete.fire(data); |
||||
}, |
||||
|
||||
setRuntimeItem: function(item){ |
||||
var runtimeItem = {}; |
||||
runtimeItem.item = item.item; |
||||
runtimeItem.attribute = {}; |
||||
for(var attr in item.attribute){ |
||||
runtimeItem.attribute[attr] = item.attribute[attr]; |
||||
if(attr == 'angle'){ |
||||
if(item.attribute[attr].start - item.attribute[attr].end > 0){ |
||||
runtimeItem.attribute[attr].perspectiveDirection = this.direction; |
||||
runtimeItem.attribute[attr].center = true; |
||||
}else{ |
||||
runtimeItem.attribute[attr].perspectiveDirection = this.direction == CoverFlow.RIGHT ? CoverFlow.LEFT : CoverFlow.RIGHT; |
||||
runtimeItem.attribute[attr].center = false; |
||||
} |
||||
} |
||||
} |
||||
this.runtimeItems.push(runtimeItem); |
||||
}, |
||||
|
||||
setItemAttributes: function(item){ |
||||
|
||||
for(var attr in item.attribute){ |
||||
|
||||
var value = Math.ceil(this.doMethod(item.attribute[attr].start, item.attribute[attr].end)); |
||||
|
||||
if(attr == 'angle'){ |
||||
item.item.setAngle(value); |
||||
var frameSize = Math.ceil(this.doMethod(3, 1)); |
||||
item.item.drawInPerspective(item.attribute[attr].perspectiveDirection, frameSize); |
||||
var left; |
||||
if(item.attribute[attr].center){ |
||||
left = this.doMethod(item.item.getLeft(), this.center - item.item.element.width/2); |
||||
}else{ |
||||
if(this.direction == CoverFlow.LEFT) |
||||
left = this.doMethod(item.item.getLeft(), this.startLeftPos - item.item.element.width); |
||||
else |
||||
left = this.doMethod(item.item.getLeft(), this.startRightPos); |
||||
} |
||||
item.item.setLeft(Math.ceil(left)); |
||||
|
||||
}else{ |
||||
item.item.setLeft(value); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
|
||||
//});
|
@ -0,0 +1,86 @@
|
||||
|
||||
|
||||
|
||||
YAHOO.util.Event.onDOMReady(function(){ |
||||
|
||||
var images = [ |
||||
{ |
||||
src: 'images/ardillitaMac.jpg', |
||||
label: 'Ardileta!', |
||||
onclick: function(){ |
||||
alert('image1'); |
||||
} |
||||
}, |
||||
{ |
||||
src: 'http://farm2.static.flickr.com/1380/1426855399_b4b8eccbdb.jpg?v=0' |
||||
}, |
||||
{ |
||||
src: 'http://farm1.static.flickr.com/69/213130158_0d1aa23576_d.jpg' |
||||
}, |
||||
{ |
||||
src: 'http://farm1.static.flickr.com/69/213130158_0d1aa23576_d.jpg' |
||||
}, |
||||
{ |
||||
src: 'images/msn2.jpg', |
||||
label: 'My Mac' |
||||
}, |
||||
{ |
||||
src: 'images/msn2.jpg', |
||||
label: 'My Mac again...' |
||||
} |
||||
|
||||
]; |
||||
var myCoverFlow = new YAHOO.ext.CoverFlow('coverFlowTest', { |
||||
height: 200, |
||||
width: 600, |
||||
images: images |
||||
}); |
||||
|
||||
function moveLeft(e, coverFlow){ |
||||
coverFlow.selectNext(); |
||||
} |
||||
function moveRight(e, coverFlow){ |
||||
coverFlow.selectPrevious(); |
||||
} |
||||
var myMoveLeftBtn = new YAHOO.widget.Button('moveLeftButton', { |
||||
onclick: { |
||||
fn: moveLeft, |
||||
obj: myCoverFlow |
||||
} |
||||
}); |
||||
var myMoveRightBtn = new YAHOO.widget.Button('moveRightButton', { |
||||
onclick: { |
||||
fn: moveRight, |
||||
obj: myCoverFlow |
||||
} |
||||
}); |
||||
|
||||
|
||||
var otherImages = [ |
||||
{ |
||||
src: 'images/ardillitaMac.jpg', |
||||
label: 'Ardileta!', |
||||
onclick: function(){ |
||||
alert('image1'); |
||||
} |
||||
}, |
||||
{ |
||||
src: 'images/msn2.jpg', |
||||
label: 'My Mac' |
||||
}, |
||||
{ |
||||
src: 'images/msn2.jpg', |
||||
label: 'My Mac again...' |
||||
} |
||||
|
||||
];
|
||||
var anotherCoverFlow = new YAHOO.ext.CoverFlow('anotherCoverFlowTest', { |
||||
height: 150, |
||||
width: 500, |
||||
images: otherImages, |
||||
bgColor: '#C0C0C0' |
||||
}); |
||||
|
||||
|
||||
|
||||
}); |
@ -1,57 +0,0 @@
|
||||
{ |
||||
"name": "islandora/islandora", |
||||
"description": "Core Islandora module", |
||||
"type": "drupal-module", |
||||
"keywords": ["Drupal", "Islandora"], |
||||
"homepage": "https://github.com/Islandora/islandora", |
||||
"support": { |
||||
"issues": "https://github.com/Islandora/documentation/issues" |
||||
}, |
||||
"repositories": [ |
||||
{ |
||||
"type": "composer", |
||||
"url": "https://packages.drupal.org/8" |
||||
} |
||||
], |
||||
"require": { |
||||
"drupal/context": "^4 || ^5@RC", |
||||
"drupal/ctools": "^3.8 || ^4", |
||||
"drupal/eva" : "^3.0", |
||||
"drupal/file_replace": "^1.1", |
||||
"drupal/filehash": "^2 || ^3", |
||||
"drupal/flysystem" : "^2.0@alpha", |
||||
"drupal/jwt": "^1.1 || ^2", |
||||
"drupal/migrate_plus" : "^5.1 || ^6", |
||||
"drupal/migrate_source_csv" : "^3.4", |
||||
"drupal/prepopulate" : "^2.2", |
||||
"drupal/search_api": "^1.8", |
||||
"drupal/token" : "^1.3", |
||||
"islandora/chullo": "^2.0", |
||||
"islandora/fedora-entity-mapper": "^1.0", |
||||
"islandora/jsonld": "^2 || ^3", |
||||
"stomp-php/stomp-php": "4.* || ^5" |
||||
}, |
||||
"require-dev": { |
||||
"phpunit/phpunit": "^6", |
||||
"squizlabs/php_codesniffer": "^2.7.1", |
||||
"drupal/coder": "*", |
||||
"sebastian/phpcpd": "*" |
||||
}, |
||||
"suggest": { |
||||
"drupal/transliterate_filenames": "Sanitizes filenames when they are uploaded so they don't break your repository.", |
||||
"drupal/coi": "Some configuration fields work with Config Override Inspector." |
||||
}, |
||||
"license": "GPL-2.0-or-later", |
||||
"authors": [ |
||||
{ |
||||
"name": "Islandora Foundation", |
||||
"email": "community@islandora.ca", |
||||
"role": "Owner" |
||||
}, |
||||
{ |
||||
"name": "Daniel Lamb", |
||||
"email": "dlamb@islandora.ca", |
||||
"role": "Maintainer" |
||||
} |
||||
] |
||||
} |
@ -1,4 +0,0 @@
|
||||
broker_url: 'tcp://localhost:61613' |
||||
jwt_expiry: '+2 hour' |
||||
delete_media_and_files: TRUE |
||||
gemini_pseudo_bundles: [] |
@ -1,13 +0,0 @@
|
||||
langcode: en |
||||
status: true |
||||
dependencies: |
||||
enforced: |
||||
module: |
||||
- islandora |
||||
module: |
||||
- islandora |
||||
id: delete_media_and_file |
||||
label: 'Delete media and file(s)' |
||||
type: media |
||||
plugin: delete_media_and_file |
||||
configuration: { } |
@ -1,244 +0,0 @@
|
||||
islandora.settings: |
||||
type: config_object |
||||
label: 'Islandora Core Settings' |
||||
mapping: |
||||
broker_url: |
||||
type: string |
||||
label: 'Url to connect to message broker' |
||||
fedora_rest_endpoint: |
||||
type: string |
||||
label: 'Url to Fedora instance' |
||||
broadcast_queue: |
||||
type: string |
||||
label: 'Queue that handles distributing messages amongst multiple recipients' |
||||
jwt_expiry: |
||||
type: string |
||||
label: 'How long JWTs should last before expiring.' |
||||
delete_media_and_files: |
||||
type: boolean |
||||
label: 'Node Delete with Media and Files' |
||||
redirect_after_media_save: |
||||
type: boolean |
||||
label: 'Redirect to node after media save.' |
||||
upload_form_location: |
||||
type: string |
||||
label: 'Upload Form Location' |
||||
upload_form_allowed_mimetypes: |
||||
type: string |
||||
label: 'Upload Form Allowed Extensions' |
||||
gemini_pseudo_bundles: |
||||
type: sequence |
||||
label: 'List of node, media and taxonomy terms that should include the linked Fedora URI' |
||||
sequence: |
||||
type: string |
||||
|
||||
|
||||
action.configuration.emit_node_event: |
||||
type: mapping |
||||
label: 'Emit a Node event to a queue/topic' |
||||
mapping: |
||||
queue: |
||||
type: text |
||||
label: 'Queue' |
||||
event: |
||||
type: text |
||||
label: 'Event Type' |
||||
|
||||
action.configuration.emit_media_event: |
||||
type: mapping |
||||
label: 'Emit a Media event to a queue/topic' |
||||
mapping: |
||||
queue: |
||||
type: text |
||||
label: 'Queue' |
||||
event: |
||||
type: text |
||||
label: 'Event Type' |
||||
|
||||
action.configuration.emit_file_event: |
||||
type: mapping |
||||
label: 'Emit a File event to a queue/topic' |
||||
mapping: |
||||
queue: |
||||
type: text |
||||
label: 'Queue' |
||||
event: |
||||
type: text |
||||
label: 'Event Type' |
||||
|
||||
action.configuration.emit_term_event: |
||||
type: mapping |
||||
label: 'Emit a Taxonomy Term event to a queue/topic' |
||||
mapping: |
||||
queue: |
||||
type: text |
||||
label: 'Queue' |
||||
event: |
||||
type: text |
||||
label: 'Event Type' |
||||
|
||||
action.configuration.delete_media_and_file: |
||||
type: action_configuration_default |
||||
label: 'Delete media and file' |
||||
|
||||
condition.plugin.node_has_term: |
||||
type: condition.plugin |
||||
mapping: |
||||
uri: |
||||
type: text |
||||
label: 'Taxonomy Term URI' |
||||
logic: |
||||
type: string |
||||
label: 'Logic (AND or OR)' |
||||
tids: |
||||
type: sequence |
||||
sequence: |
||||
type: mapping |
||||
mapping: |
||||
target_id: |
||||
type: integer |
||||
label: The target taxonomy term IDs |
||||
|
||||
condition.plugin.node_has_parent: |
||||
type: condition.plugin |
||||
mapping: |
||||
parent_nid: |
||||
type: integer |
||||
label: 'Parent node' |
||||
parent_reference_field: |
||||
type: string |
||||
label: 'Parent reference field' |
||||
|
||||
condition.plugin.media_has_term: |
||||
type: condition.plugin |
||||
mapping: |
||||
uri: |
||||
type: text |
||||
label: 'Taxonomy Term URI' |
||||
logic: |
||||
type: string |
||||
label: 'Logic (AND or OR)' |
||||
|
||||
condition.plugin.parent_node_has_term: |
||||
type: condition.plugin |
||||
mapping: |
||||
uri: |
||||
type: text |
||||
label: 'Taxonomy Term URI' |
||||
logic: |
||||
type: string |
||||
label: 'Logic (AND or OR)' |
||||
|
||||
condition.plugin.file_uses_filesystem: |
||||
type: condition.plugin |
||||
mapping: |
||||
filesystems: |
||||
type: sequence |
||||
sequence: |
||||
type: string |
||||
|
||||
condition.plugin.media_uses_filesystem: |
||||
type: condition.plugin |
||||
mapping: |
||||
filesystems: |
||||
type: sequence |
||||
sequence: |
||||
type: string |
||||
|
||||
condition.plugin.media_has_mimetype: |
||||
type: condition.plugin |
||||
mapping: |
||||
mimetypes: |
||||
type: text |
||||
label: 'Mime types' |
||||
|
||||
condition.plugin.content_entity_type: |
||||
type: condition.plugin |
||||
mapping: |
||||
types: |
||||
type: sequence |
||||
sequence: |
||||
type: string |
||||
|
||||
condition.plugin.node_had_namespace: |
||||
type: condition.plugin |
||||
mapping: |
||||
namespace: |
||||
type: text |
||||
label: 'Namespace' |
||||
pid_field: |
||||
type: ignore |
||||
label: 'PID field' |
||||
|
||||
field.formatter.settings.islandora_image: |
||||
type: field.formatter.settings.image |
||||
label: 'Islandora image field display format settings' |
||||
|
||||
condition.plugin.islandora_entity_bundle: |
||||
type: condition.plugin |
||||
mapping: |
||||
bundles: |
||||
type: sequence |
||||
sequence: |
||||
type: string |
||||
|
||||
condition.plugin.media_source_mimetype: |
||||
type: condition.plugin |
||||
mapping: |
||||
mimetype: |
||||
type: string |
||||
|
||||
reaction.plugin.alter_jsonld_type: |
||||
type: islandora.reaction_plugin_with_saved |
||||
mapping: |
||||
source_field: |
||||
type: string |
||||
|
||||
islandora.reaction_plugin_with_saved: |
||||
type: reaction.plugin |
||||
mapping: |
||||
saved: |
||||
type: boolean |
||||
label: Default config upstream; however, left undefined in the schema. |
||||
|
||||
reaction.plugin.islandora_map_uri_predicate: |
||||
type: islandora.reaction_plugin_with_saved |
||||
mapping: |
||||
drupal_uri_predicate: |
||||
type: string |
||||
|
||||
reaction.plugin.view_mode_alter: |
||||
type: islandora.reaction_plugin_with_saved |
||||
mapping: |
||||
mode: |
||||
type: string |
||||
label: The view mode to which to switch |
||||
|
||||
islandora.reaction.actions: |
||||
type: islandora.reaction_plugin_with_saved |
||||
mapping: |
||||
actions: |
||||
type: sequence |
||||
sequence: |
||||
type: string |
||||
|
||||
reaction.plugin.index: |
||||
type: islandora.reaction.actions |
||||
|
||||
reaction.plugin.delete: |
||||
type: islandora.reaction.actions |
||||
|
||||
reaction.plugin.derivative: |
||||
type: islandora.reaction.actions |
||||
|
||||
field.widget.settings.media_track: |
||||
type: field.widget.settings.file_generic |
||||
|
||||
field.field_settings.media_track: |
||||
type: field.field_settings.file |
||||
mapping: |
||||
languages: |
||||
type: string |
||||
|
||||
field.storage_settings.media_track: |
||||
type: field.storage_settings.file |
@ -0,0 +1,89 @@
|
||||
|
||||
<content_model xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Collection" version="2" xsi:schemaLocation="http://www.islandora.ca http://localhost/islandoracm.xsd"> |
||||
<mimetypes> |
||||
<type>text/xml</type> |
||||
<type>text/plain</type> |
||||
<type>application/xml</type> |
||||
</mimetypes> |
||||
<ingest_rules></ingest_rules> |
||||
<datastreams> |
||||
<datastream dsid="DC"> |
||||
<display_method class="CollectionClass" file="CollectionClass.inc" method="showFieldSets" module=""></display_method> |
||||
</datastream> |
||||
<datastream dsid="TN"></datastream> |
||||
<datastream dsid="COLLECTION_POLICY"></datastream> |
||||
</datastreams> |
||||
<ingest_form dsid="QDC" page="2"> |
||||
<form_builder_method class="CollectionFormBuilder" file="plugins/CollectionFormBuilder.inc" handler="handleQDCForm" method="buildQDCForm" module=""></form_builder_method> |
||||
<form_elements> |
||||
<element label="Title/Caption/Object Name" name="dc:title" required="true" type="textfield"> |
||||
<description>The name given to the resource</description> |
||||
</element> |
||||
<element label="Creator/Photographer/Author" name="dc:creator" type="textfield"> |
||||
<description>An entity primarily responsible for making the content of the resource such as a person, organization or service.</description> |
||||
</element> |
||||
<element label="Subject" name="dc:subject" type="select"> |
||||
<description>An entity primarily responsible for making the content of the resource such as a person, organization or service.</description> |
||||
<authoritative_list> |
||||
<item>none</item> |
||||
<item>Multi Media</item> |
||||
<item>image</item> |
||||
<item>meeting</item> |
||||
<item>presentation</item> |
||||
<item>sound</item> |
||||
<item>text</item> |
||||
</authoritative_list> |
||||
</element> |
||||
<element label="Description" name="dc:description" required="true" type="textarea"> |
||||
<description>Examples include an abstract, table of contents, or free-text account of the content of the resource.</description> |
||||
</element> |
||||
<element label="Publisher" name="dc:publisher" type="textfield"> |
||||
<description>An entity, (including persons, organizations, or services), responsible for making the resource available.</description> |
||||
</element> |
||||
<element label="Contributor" name="dc:contributor" type="textfield"> |
||||
<description>An entity responsible for contributing to the content of the resource such as a person, organization or service.</description> |
||||
</element> |
||||
<element label="Date" name="dc:date" type="textfield"> |
||||
<description>Temporal scope of the content if known. Date format is YYYY-MM-DD (e.g. 1890,1910-10,or 2007-10-23)</description> |
||||
</element> |
||||
<element label="Resource Type" name="dc:type" type="select"> |
||||
<description>Genre of the content of the resource. Examples include: home page, novel, poem, working paper, technical report, essay, dictionary.</description> |
||||
<authoritative_list> |
||||
<item>none</item> |
||||
<item>collection</item> |
||||
<item>dataset</item> |
||||
<item>event</item> |
||||
<item>image</item> |
||||
<item>interactive resource</item> |
||||
<item>model</item> |
||||
<item>party</item> |
||||
<item>physical object</item> |
||||
<item>place</item> |
||||
<item>service</item> |
||||
<item>software</item> |
||||
<item>sound</item> |
||||
<item>text</item> |
||||
</authoritative_list> |
||||
</element> |
||||
<element label="Source" name="dc:source" type="textfield"> |
||||
<description>A reference to a resource from which the present resource is derived.</description> |
||||
</element> |
||||
<element label="Identifier" name="dc:identifier" type="textfield"> |
||||
<description>A unique reference to the resource; In this instance, the accession number or collection number.</description> |
||||
</element> |
||||
<element label="Language" name="dc:language" type="select"> |
||||
<description>The language of the intellectual content of the resource.</description> |
||||
<authoritative_list> |
||||
<item field="eng">English</item> |
||||
<item field="fre">French</item> |
||||
</authoritative_list> |
||||
</element> |
||||
<element label="Relation" name="dc:relation" type="textfield"> |
||||
<description>Reference to a related resource.</description> |
||||
</element> |
||||
<element label="Rights Management" name="dc:rights" type="textarea"> |
||||
<description>Information about intellectual property rights, copyright, and various property rights.</description> |
||||
</element> |
||||
</form_elements> |
||||
</ingest_form> |
||||
</content_model> |
@ -0,0 +1,3 @@
|
||||
This directory holds content model xml files. These files should be added |
||||
as datastreams to fedora objects. The pid and datastream id are determined |
||||
by the collection policy stream of a collection object. |
@ -1,3 +0,0 @@
|
||||
.container .islandora-media-items { |
||||
margin: 0; |
||||
} |
@ -1,6 +0,0 @@
|
||||
services: |
||||
islandora.commands: |
||||
class: \Drupal\islandora\Commands\IslandoraCommands |
||||
arguments: ['@entity_type.manager', '@current_user', '@account_switcher'] |
||||
tags: |
||||
- { name: drush.command } |
@ -0,0 +1,270 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
<xsl:apply-templates select="sparql/results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="sparql/results"> |
||||
<xsl:for-each select="result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="result"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="(content='Collection' or content='Community')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/ |
||||
<xsl:value-of select="title"/>/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$linkUrl"/> |
||||
</xsl:attribute> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
</a> |
||||
<br clear="all" /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$linkUrl"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</a> |
||||
<xsl:if test="(content!='Collection' and content!='Community')"> |
||||
<br />-- |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
DETAILS |
||||
</a>-- |
||||
</xsl:if> |
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:critters="http://vre.upei.ca/critters/"> |
||||
<xsl:output method="xml" omit-xml-declaration="yes"/> |
||||
<!-- CRITTER XSLT --> |
||||
<xsl:template match="/"> |
||||
|
||||
<ul> |
||||
<li> |
||||
<b>Date Collected:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:date_collected"/> |
||||
</li> |
||||
<li> |
||||
<b>Type:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:type"/> |
||||
</li> |
||||
<li> |
||||
<b>Phylum:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:phylum"/> |
||||
</li> |
||||
<li> |
||||
<b>SubPhylum:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:SubPhylum"/> |
||||
</li> |
||||
<li> |
||||
<b>Class:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:class"/> |
||||
</li> |
||||
<li> |
||||
<b>Order:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:order"/> |
||||
</li> |
||||
<li> |
||||
<b>Family:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:family"/> |
||||
</li> |
||||
<li> |
||||
<b>Genus:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:genus"/> |
||||
</li> |
||||
<li> |
||||
<b>Species:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:taxonomy/critters:species"/> |
||||
</li> |
||||
|
||||
</ul> |
||||
|
||||
<h4>Collection Location</h4> |
||||
<ul> |
||||
<li> |
||||
<b>Site Name:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:site/critters:sitename"/> |
||||
</li> |
||||
<li> |
||||
<b>Country:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:site/critters:country"/> |
||||
</li> |
||||
<li> |
||||
<b>Region:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:site/critters:region"/> |
||||
</li> |
||||
<li> |
||||
<b>Latitude:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:site/critters:latitude"/> |
||||
</li> |
||||
<li> |
||||
<b>Longitude:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:site/critters:longitude"/> |
||||
</li> |
||||
<li> |
||||
<b>Depth:</b> |
||||
<xsl:text> </xsl:text> |
||||
<xsl:value-of select="/critters:sample/critters:site/critters:depth"/> |
||||
<xsl:text> </xsl:text>Feet |
||||
</li> |
||||
</ul> |
||||
<h4>Description</h4> |
||||
<div> |
||||
<xsl:value-of select="/critters:sample/critters:description"/> |
||||
</div> |
||||
|
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,285 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3" width="90%"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
|
||||
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<a> |
||||
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each>- |
||||
--> |
||||
<xsl:apply-templates select="sparql/results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="sparql/results"> |
||||
<xsl:for-each select="result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="result"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="(content='Collection' or content='Community')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/OBJ/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
<xsl:attribute name="alt"> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</xsl:attribute> |
||||
</img> |
||||
</a> |
||||
<br clear="all" /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</a> |
||||
|
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,264 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
<xsl:apply-templates select="sparql/results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="sparql/results"> |
||||
<xsl:for-each select="result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="result"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="(content='Collection' or content='Community')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/ |
||||
<xsl:value-of select="title"/>/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
|
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<br clear="all" /> |
||||
|
||||
|
||||
<xsl:value-of select="$newTitle"/> |
||||
|
||||
<xsl:if test="(content!='Collection' and content!='Community')"> |
||||
<br />-- |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
DETAILS |
||||
</a>-- |
||||
</xsl:if> |
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,216 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<xsl:output method="xml" omit-xml-declaration="yes"/> |
||||
<!-- refworks xslt --> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="/reference/jf"> |
||||
<h2>General Information</h2> |
||||
<table cellpadding="2" cellspacing="2"> |
||||
<tr> |
||||
<td > |
||||
<strong>Periodical:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/jf"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Abbreviation:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/jo"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Volume:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/vo"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Issue:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/is"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Publisher:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/pb"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Place of Publication:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/pp"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Edition:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/ed"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Year:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/yr"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Date:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/fd"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Start Page:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/sp"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Other Pages:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/op"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>ISSN/ISBN:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/sn"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>Language:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/la"/> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<strong>UL:</strong> |
||||
</td> |
||||
<td> |
||||
<xsl:value-of select="/reference/ul"/> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</xsl:if> |
||||
<xsl:if test="/reference/t1"> |
||||
<h2>Titles</h2> |
||||
<ul> |
||||
<xsl:for-each select="/reference/t1"> |
||||
<li> |
||||
<xsl:value-of select="."/> |
||||
</li> |
||||
</xsl:for-each> |
||||
</ul> |
||||
</xsl:if> |
||||
<xsl:if test="/reference/t2"> |
||||
<ul> |
||||
<h3>Secondary Titles</h3> |
||||
<xsl:for-each select="/reference/t2"> |
||||
<li> |
||||
<xsl:value-of select="."/> |
||||
</li> |
||||
</xsl:for-each> |
||||
</ul> |
||||
</xsl:if> |
||||
<xsl:if test="/reference/a1"> |
||||
<h2>Authors</h2> |
||||
<ul> |
||||
<xsl:for-each select="/reference/a1"> |
||||
<li> |
||||
<xsl:value-of select="."/> |
||||
</li> |
||||
</xsl:for-each> |
||||
</ul> |
||||
</xsl:if> |
||||
|
||||
<xsl:if test="/reference/a2"> |
||||
<ul> |
||||
<h3>Secondary Authors</h3> |
||||
<xsl:for-each select="/reference/a2"> |
||||
<li> |
||||
<xsl:value-of select="."/> |
||||
</li> |
||||
</xsl:for-each> |
||||
</ul> |
||||
</xsl:if> |
||||
<xsl:if test="/reference/k1"> |
||||
<h2>Keywords</h2> |
||||
<ul> |
||||
<xsl:for-each select="/reference/k1"> |
||||
<li> |
||||
<xsl:value-of select="."/> |
||||
</li> |
||||
</xsl:for-each> |
||||
</ul> |
||||
</xsl:if> |
||||
<xsl:if test="/reference/ab"> |
||||
<h2>Abstract</h2> |
||||
<xsl:for-each select="/reference/ab"> |
||||
<div> |
||||
<xsl:value-of select="."/> |
||||
</div> |
||||
</xsl:for-each> |
||||
</xsl:if> |
||||
<xsl:if test="/reference/no"> |
||||
<h2>Notes</h2> |
||||
<xsl:for-each select="/reference/no"> |
||||
<div> |
||||
<xsl:value-of select="."/> |
||||
</div> |
||||
</xsl:for-each> |
||||
</xsl:if> |
||||
<xsl:variable name="ISSN"> |
||||
<xsl:value-of select="/reference/sn"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="BASEURL"> |
||||
http://articles.library.upei.ca:7888/godot/hold_tab.cgi?hold_tab_branch=PCU&issn= |
||||
<xsl:value-of select="/reference/sn/text()"/>&date= |
||||
<xsl:value-of select="/reference/yr/text()"/>&volume= |
||||
<xsl:value-of select="/reference/vo/text()"/>&issue= |
||||
<xsl:value-of select="/reference/is/text()"/>&spage= |
||||
<xsl:value-of select="/reference/sp/text()"/>&atitle= |
||||
<xsl:value-of select="/reference/t1"/>&stitle= |
||||
<xsl:value-of select="/reference/jf"/> |
||||
</xsl:variable> |
||||
<br /> |
||||
<xsl:if test="/reference/sn"> |
||||
<div> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/> |
||||
</xsl:attribute> |
||||
<xsl:attribute name="target">_blank</xsl:attribute> |
||||
<img src="http://asin1.its.unb.ca:8000/muse/images/getit4.gif"/> |
||||
</a> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,291 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- Red and White XSLT --> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name="cellsPerRow" select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
<table cellpadding="3" cellspacing="3" width="90%"> |
||||
<tr> |
||||
<td colspan="{$cellsPerRow}"> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
<br clear="all" /> |
||||
</td> |
||||
</tr> |
||||
|
||||
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
<a> |
||||
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each>- |
||||
--> |
||||
<xsl:apply-templates select="sparql/results"/> |
||||
</table> |
||||
<br clear="all" /> |
||||
<div STYLE="text-align: center;"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template match="sparql/results"> |
||||
<xsl:for-each select="result[position() mod $cellsPerRow = 1 and position()>=$start and position() <=$end]"> |
||||
<tr> |
||||
<xsl:apply-templates select=". | following-sibling::result[position() < $cellsPerRow]"/> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</xsl:template> |
||||
<xsl:template match="result"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<xsl:variable name="newTitle" > |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="title"/> |
||||
<xsl:with-param name="from" select="'_'"/> |
||||
<xsl:with-param name="to" select="' '"/> |
||||
</xsl:call-template> |
||||
</xsl:variable> |
||||
<xsl:variable name="linkUrl"> |
||||
<xsl:choose> |
||||
<xsl:when test="(content='Collection' or content='Community')"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/OBJ/ |
||||
<xsl:value-of select="title"/>.pdf <!-- we know in riri that all OBJ streams are pdf so we can add the extension to tell browsers what it is--> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:variable> |
||||
<td valign="top" width="25%"> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$linkUrl"/> |
||||
</xsl:attribute> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
<xsl:attribute name="alt"> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</xsl:attribute> |
||||
</img> |
||||
</a> |
||||
<br clear="all" /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$linkUrl"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="$newTitle"/> |
||||
</a> |
||||
<xsl:if test="(content!='Collection' and content!='Community')"> |
||||
<br />-- |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
DETAILS |
||||
</a>-- |
||||
</xsl:if> |
||||
</td> |
||||
<xsl:if test="(position() = last()) and (position() < $cellsPerRow)"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="FillerCells"> |
||||
<xsl:param name="cellCount"/> |
||||
<td> </td> |
||||
<xsl:if test="$cellCount > 1"> |
||||
<xsl:call-template name="FillerCells"> |
||||
<xsl:with-param name="cellCount" select="$cellCount - 1"/> |
||||
</xsl:call-template> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
<xsl:template name="replace-string"> |
||||
<xsl:param name="text"/> |
||||
<xsl:param name="from"/> |
||||
<xsl:param name="to"/> |
||||
|
||||
<xsl:choose> |
||||
<xsl:when test="contains($text, $from)"> |
||||
|
||||
<xsl:variable name="before" select="substring-before($text, $from)"/> |
||||
<xsl:variable name="after" select="substring-after($text, $from)"/> |
||||
<xsl:variable name="prefix" select="concat($before, $to)"/> |
||||
|
||||
<xsl:value-of select="$before"/> |
||||
<xsl:value-of select="$to"/> |
||||
<xsl:call-template name="replace-string"> |
||||
<xsl:with-param name="text" select="$after"/> |
||||
<xsl:with-param name="from" select="$from"/> |
||||
<xsl:with-param name="to" select="$to"/> |
||||
</xsl:call-template> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$text"/> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
||||
<!-- DEFAULT XSLT FOR COLLECTIONS THAT DO NOT DEFINE THEIR OWN--> |
||||
<xsl:variable name="BASEURL"> |
||||
<xsl:value-of select="$baseUrl"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="PATH"> |
||||
<xsl:value-of select="$path"/> |
||||
</xsl:variable> |
||||
<xsl:variable name="thisPid" select="$collectionPid"/> |
||||
<xsl:variable name="thisTitle" select="$collectionTitle"/> |
||||
<xsl:variable name="size" select="20"/> |
||||
<xsl:variable name="page" select="$hitPage"/> |
||||
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> |
||||
<xsl:variable name="end" select="($start - 1) + number($size)"/> |
||||
<xsl:variable name='columns' select="4"/> |
||||
<xsl:variable name="count" select="count(sparql/results/result)"/> |
||||
<xsl:template match="/"> |
||||
<xsl:if test="$count>0"> |
||||
|
||||
<table width='100%'> |
||||
<tr> |
||||
<td colspan="2"> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
<!--select="//guestbook/entry[position()>=$start and $end>=position()]">--> |
||||
<xsl:for-each select="/sparql/results/result[position()>=$start and position() <=$end]"> |
||||
<xsl:variable name='OBJECTURI' select="object/@uri"/> |
||||
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/> |
||||
<tr> |
||||
<td> |
||||
<img> |
||||
<xsl:attribute name="src"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$PID"/>/TN |
||||
</xsl:attribute> |
||||
</img> |
||||
</td> |
||||
<td> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:copy-of select="$PID"/>/-/ |
||||
<xsl:value-of select="title"/> |
||||
</xsl:attribute> |
||||
<xsl:value-of select="title"/> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</xsl:for-each> |
||||
</table> |
||||
<div align="center"> |
||||
<xsl:choose> |
||||
<xsl:when test="$end >= $count and $start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
</xsl:when> |
||||
<xsl:when test="$end >= $count"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$count"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:when test="$start = 1"> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:when> |
||||
<xsl:otherwise> |
||||
<xsl:value-of select="$start"/>- |
||||
<xsl:value-of select="$end"/> |
||||
of |
||||
<xsl:value-of select="$count"/>  |
||||
<br /> |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page - 1"/> |
||||
</xsl:attribute> |
||||
<<Prev |
||||
</a>  |
||||
<a> |
||||
<xsl:attribute name="href"> |
||||
<xsl:value-of select="$BASEURL"/>/fedora/repository/ |
||||
<xsl:value-of select="$thisPid"/>/-/ |
||||
<xsl:value-of select="$thisTitle"/>/ |
||||
<xsl:value-of select="$page + 1"/> |
||||
</xsl:attribute> |
||||
Next>> |
||||
</a> |
||||
</xsl:otherwise> |
||||
</xsl:choose> |
||||
</div> |
||||
</xsl:if> |
||||
</xsl:template> |
||||
</xsl:stylesheet> |
@ -0,0 +1,137 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* This file defines the hooks that fedora_repository (islandora) |
||||
* makes available. |
||||
*/ |
||||
|
||||
/** |
||||
* Implements hook_islandora_tabs(). |
||||
* This hook lets one add tabs to the object page in Islandora. |
||||
* |
||||
* @param array $content_models |
||||
* An Array of content model objects. A content model is only included |
||||
* if the object actualy exists with a ISLANDORACM datastream. |
||||
* @param string $pid |
||||
* The Fedora PID of the object who's page is firing the hook. |
||||
* @param int $page_number |
||||
* Page number for collection views. |
||||
* |
||||
* @return array |
||||
* $tabset a tab definition. |
||||
*/ |
||||
function hook_islandora_tabs($content_models, $pid, $page_number) { |
||||
|
||||
$tabset['A TAB'] = array( |
||||
'#type' => 'tabpage', |
||||
'#title' => t('A TITLE'), |
||||
'#content' => 'content' |
||||
); |
||||
|
||||
return $tabset; |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_postprocess_solution_pack(). |
||||
* This hook fires after the batch job to ingest a solution pack finishes. |
||||
* |
||||
* @param string $module |
||||
* Name of the module that spcified the solution pack. |
||||
*/ |
||||
function hook_fedora_repository_postprocess_solution_pack($module) { |
||||
|
||||
// Do something that requires the objects to be ingested ie. add XACML. |
||||
return; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Implements hook_required_fedora_objects(). |
||||
* This hook lets one add objects to the repository through the |
||||
* solution pack interface. |
||||
* |
||||
* @return array |
||||
* array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', |
||||
* int dsversion, boolean required) |
||||
*/ |
||||
function hook_required_fedora_objects() { |
||||
return array( |
||||
'fedora_repository' => array( |
||||
'module' => 'fedora_repository', |
||||
'title' => 'Islandora Core', |
||||
'objects' => array( |
||||
array( |
||||
'pid' => 'islandora:collectionCModel', |
||||
'label' => 'Islandora Collection Content Model', |
||||
'dsid' => 'ISLANDORACM', |
||||
'datastream_file' => "./$module_path/content_models/COLLECTIONCM.xml", |
||||
'dsversion' => 2, |
||||
'cmodel' => 'fedora-system:ContentModel-3.0', |
||||
), |
||||
array( |
||||
'pid' => 'islandora:root', |
||||
'label' => 'Islandora Top-level Collection', |
||||
'cmodel' => 'islandora:collectionCModel', |
||||
'datastreams' => array( |
||||
array( |
||||
'dsid' => 'COLLECTION_POLICY', |
||||
'datastream_file' => "./$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", |
||||
), |
||||
array( |
||||
'dsid' => 'TN', |
||||
'datastream_file' => "./$module_path/images/Gnome-emblem-photos.png", |
||||
'mimetype' => 'image/png', |
||||
), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_fedora_repository_can_ingest(). |
||||
* Override ingest permissions. |
||||
* (from islandora_workflow) |
||||
* |
||||
* @deprecated |
||||
* Deprecated in favour of hook_fedora_repository_check_perm(). |
||||
* @param string $collection_pid |
||||
* The PID of the collection |
||||
* |
||||
* @return boolean |
||||
* TRUE if the user can ingest into the specified collection, FALSE otherwise. |
||||
*/ |
||||
function hook_fedora_repository_can_ingest($collection_pid) { |
||||
|
||||
module_load_include('inc', 'islandora_workflow', 'islandora_workflow.permissions'); |
||||
return (islandora_workflow_user_collection_permission_check($collection_pid) !== FALSE); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Implements hook_fedora_repository_check_perm(). |
||||
* |
||||
* Hook to allow other modules to allow or deny operations on conditions other |
||||
* than the explicit Drupal permissions. |
||||
* |
||||
* @param string $op |
||||
* A string representing the operation to be performed. |
||||
* @param string|null $pid |
||||
* A string containing the Fedora PID on which the operation is to be |
||||
* performed. The (default) value of NULL will use the PID indicated by the |
||||
* fedora_repository_pid Drupal variable. |
||||
* @param object|null $as_user |
||||
* An object representing the user for whom to check the permissions (as |
||||
* given by user_load or the $user global). The (default) value of NULL will |
||||
* cause permissions to be evaluated for the current user (from the $user |
||||
* global). |
||||
* |
||||
* @return boolean|null |
||||
* Either a boolean permitting (TRUE) or forbidding (FALSE) an operation, or |
||||
* NULL to make no assertion. |
||||
*/ |
||||
function hook_fedora_repository_check_perm($op, $pid = NULL, $as_user = NULL) { |
||||
return NULL; |
||||
} |
@ -0,0 +1,8 @@
|
||||
name = Islandora Repository |
||||
dependencies[] = imageapi |
||||
dependencies[] = tabs |
||||
dependencies[] = islandora_content_model_forms |
||||
description = Shows a list of items in a fedora collection. |
||||
package = Islandora |
||||
version = 6.x-12.3.0-RC |
||||
core = 6.x |
@ -0,0 +1,134 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file fedora_repository.install |
||||
*/ |
||||
|
||||
/** |
||||
* Implementation of hook_enable(). |
||||
*/ |
||||
function fedora_collections_enable() { |
||||
//nothing to do as we do not currently touch the drupal database. |
||||
//other than the variables table |
||||
} |
||||
|
||||
/** |
||||
* Implementation of hook_requirements(). |
||||
* |
||||
* @return |
||||
* An array describing the status of the site regarding available updates. |
||||
* If there is no update data, only one record will be returned, indicating |
||||
* that the status of core can't be determined. If data is available, there |
||||
* will be two records: one for core, and another for all of contrib |
||||
* (assuming there are any contributed modules or themes enabled on the |
||||
* site). In addition to the fields expected by hook_requirements ('value', |
||||
* 'severity', and optionally 'description'), this array will contain a |
||||
* 'reason' attribute, which is an integer constant to indicate why the |
||||
* given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or |
||||
* UPDATE_UNKNOWN). This is used for generating the appropriate e-mail |
||||
* notification messages during update_cron(), and might be useful for other |
||||
* modules that invoke update_requirements() to find out if the site is up |
||||
* to date or not. |
||||
* |
||||
* @see _update_message_text() |
||||
* @see _update_cron_notify() |
||||
*/ |
||||
function fedora_repository_requirements($phase) { |
||||
$requirements = array(); |
||||
$t = get_t(); //May not have access to the regular t() function; and so Drupal provides... |
||||
|
||||
if ($phase == 'install') { |
||||
|
||||
// Test for SOAP |
||||
$requirements['fedora-soap']['title'] = $t("PHP SOAP extension library"); |
||||
if (!class_exists('SoapClient')) { |
||||
$requirements['fedora-soap']['value'] = $t("Not installed"); |
||||
$requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR; |
||||
$requirements['fedora-soap']['description'] = $t('Ensure that the PHP SOAP extension is installed.'); |
||||
} |
||||
else { |
||||
$requirements['fedora-soap']['value'] = $t("Installed"); |
||||
$requirements['fedora-soap']['severity'] = REQUIREMENT_OK; |
||||
} |
||||
|
||||
// Test for Curl |
||||
$requirements['curl']['title'] = $t('PHP Curl extension library'); |
||||
if (!function_exists('curl_init')) { |
||||
$requirements['curl']['value'] = $t("Not installed"); |
||||
$requirements['curl']['severity'] = REQUIREMENT_ERROR; |
||||
$requirements['curl']['description'] = $t("Ensure that the PHP Curl extension is installed."); |
||||
} |
||||
else { |
||||
$requirements['curl']['value'] = $t("Installed"); |
||||
$requirements['curl']['severity'] = REQUIREMENT_OK; |
||||
} |
||||
|
||||
// Test for DOM |
||||
$requirements['dom']['title'] = $t("PHP DOM XML extension library"); |
||||
if (!method_exists('DOMDocument', 'loadHTML')) { |
||||
$requirements['dom']['value'] = $t("Not installed"); |
||||
$requirements['dom']['severity'] = REQUIREMENT_ERROR; |
||||
$requirements['dom']['description'] = $t("Ensure that the PHP DOM XML extension is installed."); |
||||
} |
||||
else { |
||||
$requirements['dom']['value'] = $t("Installed"); |
||||
$requirements['dom']['severity'] = REQUIREMENT_OK; |
||||
} |
||||
|
||||
// Test for XSLT |
||||
$requirements['xsl']['title'] = $t("PHP XSL extension library"); |
||||
if (!class_exists('XSLTProcessor')) { |
||||
$requirements['xslt']['value'] = $t("Not installed"); |
||||
$requirements['xslt']['severity'] = REQUIREMENT_ERROR; |
||||
$requirements['xslt']['description'] = $t("Ensure that the PHP XSL extension is installed."); |
||||
} |
||||
else { |
||||
$requirements['xslt']['value'] = $t("Installed"); |
||||
$requirements['xslt']['severity'] = REQUIREMENT_OK; |
||||
} |
||||
} |
||||
elseif ($phase == 'runtime') { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
||||
|
||||
$requirements['fedora-repository']['title'] = $t("Fedora server"); |
||||
if (!fedora_available()) { |
||||
$requirements['fedora-repository']['value'] = $t("Not available"); |
||||
$requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; |
||||
$requirements['fedora-repository']['description'] = $t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => url('admin/settings/fedora_repository'))); |
||||
} |
||||
else { |
||||
$requirements['fedora-repository']['value'] = $t("Available"); |
||||
$requirements['fedora-repository']['severity'] = REQUIREMENT_OK; |
||||
} |
||||
} |
||||
|
||||
return $requirements; |
||||
} |
||||
|
||||
/** |
||||
* Implements hook_update_N(). |
||||
* |
||||
* This function will try and update the SOAP WSDLs |
||||
* as they were set wrong in previous releases. |
||||
*/ |
||||
function fedora_repository_update_6001() { |
||||
// Get variables to check for update. |
||||
$API_A_WSDL = variable_get('fedora_soap_url', $default = NULL); |
||||
$API_M_WSDL = variable_get('fedora_soap_manage_url', $default = NULL); |
||||
|
||||
// Update API A if necessary. |
||||
$A_WSDL = parse_url($API_A_WSDL, PHP_URL_PATH) . '?' . parse_url($API_A_WSDL, PHP_URL_QUERY); |
||||
if ($A_WSDL == '/fedora/services/access?wsdl') { |
||||
variable_set('fedora_soap_url', str_replace('/fedora/services/access?wsdl', '/fedora/wsdl?api=API-A', $API_A_WSDL)); |
||||
} |
||||
|
||||
// Update API M if necessary. |
||||
$M_WSDL = parse_url($API_M_WSDL, PHP_URL_PATH) . '?' . parse_url($API_M_WSDL, PHP_URL_QUERY); |
||||
if ($M_WSDL == '/fedora/services/management?wsdl') { |
||||
variable_set('fedora_soap_manage_url', str_replace('/fedora/services/management?wsdl', '/fedora/wsdl?api=API-M', $API_M_WSDL)); |
||||
} |
||||
|
||||
return array( |
||||
array('success' => TRUE, 'query' => 'Please check your WSDL paths in Islandora\'s config, this update requires them to be set correctly: access; /fedora/wsdl?api=API-A, management; /fedora/wsdl?api=API-M'), |
||||
); |
||||
} |
@ -0,0 +1,259 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* Invokes a hook to any dependent modules asking them if their |
||||
* installations require any fedora objects to be present. |
||||
* Modules implementing this hook should return an array |
||||
* of arrays of the form: |
||||
* |
||||
* array( 'pid', 'path-to-foxml-file', |
||||
* 'dsid', |
||||
* 'path-to-datastream-file', |
||||
* int dsversion) |
||||
* |
||||
* where the last three options are optional. |
||||
* A module can either point to a simple foxml file to install, |
||||
* or can specify a datastreamstream to check for, with a |
||||
* path to load the datastream from if it isn't there. |
||||
* Optionally a version number can be included, |
||||
* to enable updating of content model or collection policy streams |
||||
* that may have been updated. |
||||
* This is a simple whole number that should be incremented when changed. |
||||
* This value appears in as an attribute of the topmost element of the stream, |
||||
* e.g.,: |
||||
* |
||||
* <?xml version="1.0" encoding="utf-8"?> |
||||
* <content_model name="Collection" version="2" ... |
||||
* |
||||
* Datastreams which don't have this element are assumed to be at version 0. |
||||
*/ |
||||
|
||||
/** |
||||
* Builds the tab for the solution packs. |
||||
*/ |
||||
function fedora_repository_solution_packs_page() { |
||||
$enabled_solution_packs = module_invoke_all('fedora_repository_required_fedora_objects'); |
||||
$output = ''; |
||||
foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) { |
||||
$objects = array(); |
||||
foreach ($solution_pack_info as $field => $value) { |
||||
switch ($field) { |
||||
case 'title': |
||||
$solution_pack_name = $value; |
||||
break; |
||||
case 'objects': |
||||
$objects = $value; |
||||
break; |
||||
} |
||||
} |
||||
$output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); |
||||
} |
||||
|
||||
return $output; |
||||
} |
||||
|
||||
/** |
||||
* Check for installed objects and add a 'Update' or 'Install' button if |
||||
* some objects are missing. |
||||
* |
||||
* @param array &$form_state |
||||
* The current state of the form. |
||||
* @param unknown $solution_pack_module |
||||
* Module name of that solution pack. |
||||
* @param string $solution_pack_name |
||||
* Human readable name for the solution pack. |
||||
* @param array $objects |
||||
* Defaults to an empty array. |
||||
*/ |
||||
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { |
||||
|
||||
// Check each object to see if it is in the repository. |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
global $base_path; |
||||
$needs_update = FALSE; |
||||
$needs_install = FALSE; |
||||
$form = array(); |
||||
|
||||
$form['solution_pack_module'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => $solution_pack_module, |
||||
); |
||||
|
||||
if (!$form_state['submitted']) { |
||||
$form['solution_pack_name'] = array( |
||||
'#type' => 'markup', |
||||
'#value' => t($solution_pack_name), |
||||
'#prefix' => '<h3>', |
||||
'#suffix' => '</h3>', |
||||
); |
||||
$form['objects'] = array( |
||||
'#type' => 'fieldset', |
||||
'#title' => "Objects", |
||||
'#weight' => 10, |
||||
'#attributes' => array('class' => 'collapsed'), |
||||
'#collapsible' => TRUE, |
||||
'#collapsed' => TRUE, |
||||
); |
||||
$table_header = array('PID', 'Status'); |
||||
$table_rows = array(); |
||||
|
||||
foreach ($objects as $object) { |
||||
$datastreams = NULL; |
||||
if (isset($object['pid'])) { |
||||
$pid = $object['pid']; |
||||
|
||||
$item = new Fedora_Item($pid); |
||||
$table_row = array($object['pid']); |
||||
$object_status = t('Up-to-date'); |
||||
if (!$item->exists()) { |
||||
$object_status = 'Missing'; |
||||
$needs_install = TRUE; |
||||
} |
||||
else { |
||||
if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { |
||||
$datastreams = array( |
||||
array( |
||||
'dsid' => $object['dsid'], |
||||
'datastream_file' => $object['datastream_file'], |
||||
'dsversion' => $object['dsversion'], |
||||
), |
||||
); |
||||
} |
||||
elseif (!empty($object['datastreams'])) { |
||||
$datastreams = $object['datastreams']; |
||||
} |
||||
if (!empty($datastreams) && is_array($datastreams)) { |
||||
foreach ($datastreams as $ds) { |
||||
$ds_list = $item->get_datastreams_list_as_array(); |
||||
if (!array_key_exists($ds['dsid'], $ds_list)) { |
||||
$needs_update = TRUE; |
||||
$object_status = 'Missing datastream'; |
||||
break; |
||||
} |
||||
elseif (isset($ds['dsversion'])) { |
||||
// Check if the datastream is versioned and needs updating. |
||||
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); |
||||
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); |
||||
|
||||
if ($available_version > $installed_version) { |
||||
$needs_update = TRUE; |
||||
$object_status = 'Out of date'; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
array_push($table_row, $object_status); |
||||
$table_rows[] = $table_row; |
||||
} |
||||
} |
||||
$form['objects']['table'] = array( |
||||
'#type' => 'markup', |
||||
'#value' => theme_table($table_header, $table_rows), |
||||
); |
||||
} |
||||
|
||||
$form['install_status'] = array( |
||||
'#type' => 'markup', |
||||
'#prefix' => '<strong>' . t('Object status:') . ' </strong>', |
||||
'#suffix' => ' ', |
||||
); |
||||
if (!$needs_install && !$needs_update) { |
||||
$form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); |
||||
$submit_button_text = t("Force Reinstallation of Fedora Objects"); |
||||
|
||||
} |
||||
else { |
||||
$form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); |
||||
$submit_button_text = t("Install Fedora Objects"); |
||||
|
||||
} |
||||
$form['submit'] = array( |
||||
'#value' => $submit_button_text, |
||||
'#type' => 'submit', |
||||
'#name' => $solution_pack_module, |
||||
); |
||||
|
||||
$form['#submit'] = array( |
||||
'fedora_repository_solution_pack_form_submit', |
||||
); |
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Submit handler for solution pack form. |
||||
* |
||||
* @param array $form |
||||
* The form submitted. |
||||
* @param array_reference $form_state |
||||
* The state of the form submited. |
||||
*/ |
||||
function fedora_repository_solution_pack_form_submit($form, &$form_state) { |
||||
|
||||
$module_name = $form_state['values']['solution_pack_module']; |
||||
|
||||
$solution_pack_info = module_invoke($module_name, 'fedora_repository_required_fedora_objects'); |
||||
|
||||
$batch = array( |
||||
'title' => t('Installing / updating solution pack objects'), |
||||
'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', |
||||
'operations' => array(), |
||||
); |
||||
|
||||
|
||||
foreach ($solution_pack_info[$module_name]['objects'] as $object) { |
||||
// Add this object to the batch job queue. |
||||
// Module name is needed in the finished callback. |
||||
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object, $module_name)); |
||||
} |
||||
|
||||
// Tell the batch to call the function to send out a postprocess hook. |
||||
$batch['finished'] = 'fedora_repository_solutionpack_send_postprocess'; |
||||
|
||||
batch_set($batch); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Writes a form entry into the database. |
||||
* |
||||
* @param string $form_name |
||||
* The name of the form. |
||||
* @param unknown_type $form_xml |
||||
* The form definition. |
||||
*/ |
||||
function solution_pack_add_form($form_name, $form_xml) { |
||||
$result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name)); |
||||
if (!$result) { |
||||
$object = new stdClass(); |
||||
$object->name = $form_name; |
||||
$object->form = $form_xml; |
||||
$result = drupal_write_record('xml_forms', $object); |
||||
drupal_set_message(t("Added @name", array("@name" => $form_name))); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Writes a form association to the database |
||||
* |
||||
* @param string $content_model |
||||
* content model PID |
||||
* @param string $form_name |
||||
* Name of the form |
||||
*/ |
||||
function solution_pack_add_form_association($content_model, $form_name) { |
||||
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', |
||||
$content_model, $form_name)); |
||||
if (!$result) { |
||||
$object = new stdClass(); |
||||
$object->content_model = $content_model; |
||||
$object->form_name = $form_name; |
||||
$object->dsid = 'MODS'; |
||||
$object->title_field = "['titleInfo']['title']"; |
||||
$object->transform = 'mods_to_dc.xsl'; |
||||
$result = drupal_write_record('islandora_content_model_forms', $object); |
||||
drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name" => $form_name))); |
||||
} |
||||
} |
@ -0,0 +1,161 @@
|
||||
<?php |
||||
|
||||
|
||||
/** |
||||
* @file |
||||
* Generic test case to be extended to implement Islandora testing. |
||||
* |
||||
* In order to use this properly, you must place a test user in |
||||
* your Fedora installation. Please add the follwing snippet to your |
||||
* $FEDORA_HOME/server/config/fedora-users.xml: |
||||
* |
||||
* <user name="simpletestuser" password="41fe63c9636c6649f0a4747400f0f95e"> |
||||
* <attribute name="fedoraRole"> |
||||
* <value>administrator</value> |
||||
* </attribute> |
||||
* </user> |
||||
*/ |
||||
abstract class IslandoraTestCase extends DrupalWebTestCase { |
||||
|
||||
/** |
||||
* User with the rights required to perform the test |
||||
*/ |
||||
protected $privileged_user; |
||||
|
||||
/** |
||||
* Override this method to provide the name of the module, |
||||
* e.g. the name of the .module file |
||||
* |
||||
* @return string - The name of the module |
||||
*/ |
||||
abstract protected function getModuleName(); |
||||
|
||||
/** |
||||
* Returns basic permissions needed for running Islandora tests. |
||||
* Override this method to provide additional permissions, but |
||||
* be sure to append your new permissions to the return value |
||||
* of parent::getUserPermissions and return that. |
||||
* |
||||
* @return array - An array of strings describing permissions |
||||
*/ |
||||
protected function getUserPermissions() { |
||||
return array( |
||||
'access content', |
||||
'add fedora datastreams', |
||||
'edit fedora meta data', |
||||
'edit tags datastream', |
||||
'ingest new fedora objects', |
||||
'purge objects and datastreams', |
||||
'view fedora collection', |
||||
'view detailed list of content', |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Creates a user with permissions required for the test, and logs in. |
||||
*/ |
||||
protected function createPrivilegedUser() { |
||||
// Create a role with the permissions from getUserPermissions() |
||||
$role = $this->drupalCreateRole($this->getUserPermissions()); |
||||
|
||||
// Create a user model |
||||
$user = array( |
||||
'name' => 'simpletestuser', |
||||
'mail' => 'simpletestuser@example.com', |
||||
'roles' => array( $role => $role ), |
||||
'pass' => 'simpletestpass', |
||||
'status' => 1, |
||||
); |
||||
|
||||
// Create a user from the model |
||||
$this->privileged_user = user_save('', $user); |
||||
|
||||
// Add the raw password so we can log in |
||||
$this->privileged_user->pass_raw = $user['pass']; |
||||
|
||||
// Log in |
||||
!$this->drupalLogin($this->privileged_user); |
||||
} |
||||
|
||||
/** |
||||
* Automatically generates all module dependencies and enables them in order. |
||||
* Also logs in a privileged user with the appropriate permissions for the |
||||
* test. |
||||
* |
||||
* If you need to override this method to provide extra functionality, |
||||
* please be sure to call parent::setUp so dependency resolution and |
||||
* authentication still happen. |
||||
*/ |
||||
public function setUp() { |
||||
// Grab all the available modules |
||||
$modules = module_rebuild_cache(); |
||||
|
||||
// Grab the module to test's dependencies |
||||
$dependencies = $modules[$this->getModuleName()]->info['dependencies']; |
||||
|
||||
// Sort them so they're in the correct order to enable |
||||
$dependencies = array_reverse($dependencies); |
||||
|
||||
// Add our module to the end |
||||
$dependencies[] = $this->getModuleName(); |
||||
|
||||
// Enable the module's dependencies in order |
||||
call_user_func_array('parent::setUp', $dependencies); |
||||
|
||||
// Authenticate the privileged user |
||||
$this->createPrivilegedUser(); |
||||
} |
||||
|
||||
public function invoke($hook_name) { |
||||
$args = func_get_args(); |
||||
array_unshift($args, $this->getModuleName()); |
||||
return call_user_func_array('module_invoke', $args); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Class containing tests that are common to all solution packs. |
||||
*/ |
||||
abstract class SolutionPackTestCase extends IslandoraTestCase { |
||||
|
||||
/** |
||||
* Tests the fedora_repository_required_fedora_objects hook. |
||||
* |
||||
* Validates the schema of the array returned by the hook. The array should |
||||
* be roughly of the form: |
||||
* [ |
||||
* module_name => |
||||
* [ |
||||
* 'module' => module_name, |
||||
* 'title' => module_title, |
||||
* 'objects' => |
||||
* [ |
||||
* ... |
||||
* ] |
||||
* ] |
||||
* ] |
||||
* |
||||
* Where each entry of the 'objects' sub-array should be arrays themselves, |
||||
* each containing the information needed for drupal_get_form(). |
||||
* |
||||
* Note that the root key of the array is the actual module name (e.g. |
||||
* islandora_audio_sp, islandora_image_sp, etc...), not 'module_name' |
||||
*/ |
||||
public function testFedoraRepositoryRequiredFedoraObjects() { |
||||
|
||||
// Invoke the hook |
||||
$results = $this->invoke('fedora_repository_required_fedora_objects'); |
||||
|
||||
// Validate the schema of the returned data structure |
||||
$this->assertNotNull($results, 'A non-null result was returned from the fedora_repository_required_fedora_objects hook.'); |
||||
$this->assertTrue(is_array($results), 'An array was returned from the fedora_repository_required_fedora_objects hook.'); |
||||
$this->assertTrue(array_key_exists($this->getModuleName(), $results), "Returned array has top level key that is equal to the module's short form name"); |
||||
$this->assertTrue(is_array($results[$this->getModuleName()]), "Value associated with top level key that is equal to the module's short form name is an array"); |
||||
$this->assertTrue(array_key_exists('module', $results[$this->getModuleName()]), "Top level array has 'module' key"); |
||||
$this->assertEqual($results[$this->getModuleName()]['module'], $this->getModuleName(), "Value associated with 'module' key is equal to the module's short form name"); |
||||
$this->assertTrue(array_key_exists('title', $results[$this->getModuleName()]), "Top level array has 'title' key"); |
||||
$this->assertTrue($results[$this->getModuleName()]['title'], "Title string is not empty"); |
||||
$this->assertTrue(array_key_exists('objects', $results[$this->getModuleName()]), "Returned array has second level key equal to 'object'"); |
||||
$this->assertTrue(is_array($results[$this->getModuleName()]['objects']), "Value associated with second level 'object' key is an array"); |
||||
} |
||||
} |
@ -0,0 +1,938 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* @file |
||||
* formClass class |
||||
*/ |
||||
|
||||
/** |
||||
* form Class |
||||
*/ |
||||
class formClass { |
||||
|
||||
function formClass() { |
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
||||
} |
||||
|
||||
/** |
||||
* Create the paths for urls and map them to php functions |
||||
* @return array |
||||
*/ |
||||
function createMenu() { |
||||
$items = array(); |
||||
|
||||
$items['admin/settings/fedora_repository'] = array( |
||||
'title' => t('Islandora Configuration'), |
||||
'description' => t("Configure Islandora's interaction with Fedora"), |
||||
'page callback' => 'drupal_get_form', |
||||
'page arguments' => array('fedora_repository_admin'), |
||||
'access arguments' => array('administer site configuration'), |
||||
'type' => MENU_NORMAL_ITEM, |
||||
); |
||||
$items['admin/settings/fedora_repository/collection'] = array( |
||||
'title' => t('Collection list'), |
||||
'description' => t('Enter the Islandora collection information here.'), |
||||
'access arguments' => array('administer site configuration'), |
||||
'type' => MENU_DEFAULT_LOCAL_TASK, |
||||
'weight' => 0, |
||||
); |
||||
|
||||
$items['admin/settings/fedora_repository/demoobjects'] = array( |
||||
'title' => t('Solution Packs'), |
||||
'description' => t('Install content models and collections required by installed solution packs.'), |
||||
'page callback' => 'fedora_repository_solution_packs_page', |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('add fedora datastreams'), |
||||
'file' => 'fedora_repository.solutionpacks.inc', |
||||
'type' => MENU_LOCAL_TASK, |
||||
); |
||||
$items['islandoracm.xsd'] = array( |
||||
'title' => t('Islandora Content Model XML Schema Definition'), |
||||
'page callback' => 'fedora_repository_display_schema', |
||||
'page arguments' => array('islandoracm.xsd'), |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('view fedora collection'), |
||||
); |
||||
|
||||
$items['collection_policy.xsd'] = array( |
||||
'title' => t('Islandora Content Model XML Schema Definition'), |
||||
'page callback' => 'fedora_repository_display_schema', |
||||
'page arguments' => array('collection_policy.xsd'), |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('view fedora collection'), |
||||
); |
||||
|
||||
$items['fedora'] = array( |
||||
'page callback' => 'repository_page', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('view fedora collection', 1), |
||||
); |
||||
$items['fedora/repository'] = array( |
||||
'title' => 'Digital Repository', |
||||
'page callback' => 'repository_page', |
||||
'type' => MENU_NORMAL_ITEM, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('view fedora collection', 2), |
||||
); |
||||
|
||||
$items['fedora/repository/service'] = array( |
||||
'page callback' => 'repository_service', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('view fedora collection'), |
||||
); |
||||
|
||||
$items['fedora/repository/object_download'] = array( |
||||
'title' => t('Download object'), |
||||
'page callback' => 'fedora_object_as_attachment', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('view fedora collection') |
||||
); |
||||
|
||||
$items['fedora/repository/editmetadata'] = array( |
||||
'title' => t('Edit metadata'), |
||||
'page callback' => 'fedora_repository_edit_qdc_page', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('edit fedora meta data', 3) |
||||
); |
||||
|
||||
$items['fedora/repository/purgeStream'] = array( |
||||
'title' => t('Purge data stream'), |
||||
'page callback' => 'fedora_repository_purge_stream', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('purge objects and datastreams', 3) |
||||
); |
||||
|
||||
$items['fedora/repository/replaceStream'] = array( |
||||
'title' => t('Replace Stream'), |
||||
'page callback' => 'fedora_repository_replace_stream', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('add fedora datastreams', 3), |
||||
); |
||||
|
||||
$items['fedora/repository/purgeObject'] = array( |
||||
'title' => t('Purge object'), |
||||
'page callback' => 'fedora_repository_purge_object', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('purge objects and datastreams', 3) |
||||
); |
||||
|
||||
$items['fedora/repository/addStream'] = array( |
||||
'title' => t('Add stream'), |
||||
'page callback' => 'add_stream', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('add fedora datastreams', 3) |
||||
); |
||||
|
||||
$items['fedora/ingestObject'] = array( |
||||
'title' => t('Ingest object'), |
||||
'page callback' => 'fedora_repository_ingest_object', |
||||
'type' => MENU_CALLBACK, |
||||
'access callback' => 'fedora_repository_check_perm', |
||||
'access arguments' => array('add fedora datastreams', 2) |
||||
); |
||||
|
||||
$items['admin/settings/fedora_repository/object_details_xslt'] = array( |
||||
'title' => "", |
||||
'type' => MENU_CALLBACK, |
||||
'page callback' => 'drupal_get_form', |
||||
'page arguments' => array('fedora_repository_object_details_XSLT_config'), |
||||
'file' => 'ObjectDetails.inc', |
||||
'access arguments' => array('administer site configuration'), |
||||
); |
||||
$items['admin/settings/fedora_repository/object_details_table'] = array( |
||||
'title' => "", |
||||
'type' => MENU_CALLBACK, |
||||
'page callback' => 'drupal_get_form', |
||||
'page arguments' => array('fedora_repository_object_details_table_config'), |
||||
'file' => 'ObjectDetails.inc', |
||||
'access arguments' => array('administer site configuration'), |
||||
); |
||||
|
||||
return $items; |
||||
} |
||||
|
||||
/** |
||||
* Create admin form |
||||
* @return array |
||||
*/ |
||||
function createAdminForm() { |
||||
if (!user_access('administer site configuration')) { |
||||
drupal_set_message(t('You must be a site administrator to edit the Fedora collections list.'), 'error'); |
||||
return; |
||||
} |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
$form = array(); |
||||
$form['fedora_repository_pid'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Root Collection PID'), |
||||
'#default_value' => variable_get('fedora_repository_pid', 'islandora:root'), |
||||
'#description' => t('The PID of the Root Collection Object'), |
||||
'#required' => TRUE, |
||||
'#weight' => -18 |
||||
); |
||||
|
||||
$form['fedora_base_url'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Fedora base URL'), |
||||
'#default_value' => variable_get('fedora_base_url', 'http://localhost:8080/fedora'), |
||||
'#description' => t('The URL to use for REST-type connections'), |
||||
'#required' => TRUE, |
||||
'#weight' => -16, |
||||
); |
||||
|
||||
|
||||
$form['fedora_repository_url'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Fedora RISearch URL'), |
||||
'#default_value' => variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'), |
||||
'#description' => t('The url of the Fedora server'), '#required' => TRUE, |
||||
'#weight' => -14 |
||||
); |
||||
|
||||
$form['fedora_soap_url'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Fedora SOAP Url'), |
||||
'#default_value' => variable_get('fedora_soap_url', 'http://localhost:8080/fedora/wsdl?api=API-A'), |
||||
'#description' => t('The URL to use for SOAP connections'), |
||||
'#required' => TRUE, |
||||
'#weight' => -12, |
||||
'#suffix' => '<p>' . ( |
||||
fedora_available() ? |
||||
theme('image', 'misc/watchdog-ok.png') . t('Successfully connected to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', ''))) : |
||||
theme('image', 'misc/watchdog-error.png') . t('Unable to connect to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', '')))) . '</p>', |
||||
); |
||||
|
||||
$form['fedora_soap_manage_url'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Fedora SOAP management URL'), |
||||
'#default_value' => variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M'), '#description' => t('The URL to use for SOAP API-M connections'), |
||||
'#required' => TRUE, |
||||
'#weight' => -10 |
||||
); |
||||
|
||||
// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php |
||||
if (variable_get('allow_open_namespace', TRUE)) { |
||||
$form['fedora_namespace'] = array( |
||||
'#type' => 'fieldset', |
||||
); |
||||
|
||||
$form['fedora_namespace']['fedora_namespace_restriction_enforced'] = array( |
||||
'#weight' => -1, |
||||
'#type' => 'radios', |
||||
'#title' => t('Enforce namespace restrictions'), |
||||
'#options' => array( |
||||
TRUE => t('Enabled'), |
||||
FALSE => t('Disabled') |
||||
), |
||||
'#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'), |
||||
'#default_value' => variable_get('fedora_namespace_restriction_enforced', TRUE) |
||||
); |
||||
|
||||
$form['fedora_namespace']['fedora_pids_allowed'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('PID namespaces allowed in this Drupal install'), |
||||
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '), |
||||
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'), |
||||
'#weight' => 0 |
||||
); |
||||
} |
||||
else { |
||||
$form['fedora_pids_allowed'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('PID namespaces allowed in this Drupal install'), |
||||
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '), |
||||
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'), |
||||
'#weight' => 0 |
||||
); |
||||
} |
||||
|
||||
//have tabs options (like disable) |
||||
$form['tabs'] = array( |
||||
'#type' => 'fieldset', |
||||
'#title' => t('Tabs Configuration'), |
||||
'#description' => t('Configure the tabs available when viewing Fedora objects.'), |
||||
'#collapsible' => TRUE, |
||||
'#collapsed' => TRUE, |
||||
); |
||||
|
||||
//when checked show object details tab |
||||
$form['tabs']['fedora_repository_show_object_details_tab'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t('Show Object Details Tab'), |
||||
'#default_value' => variable_get('fedora_repository_show_object_details_tab', TRUE), |
||||
'#description' => t("When enabled, the 'Object Details' tab will be visible to users with the correct permissions when viewing an object in the repository"), |
||||
); |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'ObjectDetails'); |
||||
$primary_display_mode = variable_get('islandora_object_details_display_table', 'xslt'); |
||||
$profiles = module_invoke_all("islandora_object_details_display"); |
||||
|
||||
$display_options = array(); |
||||
// suppress php warnings from empty lists |
||||
if ($profiles) { |
||||
foreach ($profiles as $machine_name => $profile) { |
||||
// make sure the name exists (the bare minimum) |
||||
if (array_key_exists('name', $profile)) { |
||||
$display_options[$machine_name] = $profile['name']; |
||||
if (array_key_exists('config', $profile)) { |
||||
$config_path = $profile['config']; |
||||
if (isset($config_path) && $config_path != "") { |
||||
$display_options[$machine_name] .= " (". l("config", $config_path, array()) .")"; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
$form['tabs']['islandora_object_details_display_table'] = array( |
||||
'#type' => 'radios', |
||||
'#title' => t('Show object details as'), |
||||
'#options' => $display_options, |
||||
'#default_value' => $primary_display_mode, |
||||
'#description' => t("Tells Islandora how to display the object details page for each object"), |
||||
); |
||||
|
||||
$form['advanced'] = array( |
||||
'#type' => 'fieldset', |
||||
'#title' => t('Advanced configuration options'), |
||||
'#description' => t('Advanced configuration. Under normal circumstances these will not be touched'), |
||||
'#collapsible' => TRUE, |
||||
'#collapsed' => TRUE, |
||||
); |
||||
|
||||
$form['advanced']['fedora_object_restrict_datastreams'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t('Restrict Access to Fedora Object Datastreams'), |
||||
'#default_value' => variable_get('fedora_object_restrict_datastreams', FALSE), |
||||
'#description' => t('When enabled, restricts access to fedora object datastreams that are not listed in the Islandora Content Model for the object (unless the user is an administrator).'), |
||||
); |
||||
|
||||
$form['advanced']['fedora_repository_use_imagecache_external_in_collection_view'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t('Allow imagecache_external use for thumbnails in collection view'), |
||||
'#default_value' => variable_get('fedora_repository_use_imagecache_external_in_collection_view', FALSE), |
||||
'#description' => t('If enabled, the default collection list view (or ' . |
||||
'anywhere the function "@function" is used) will try to use ' . |
||||
'imagecache_external, defaulting to the "@preset" preset. XSLTs may ' . |
||||
'be updated to use this function.', |
||||
array( |
||||
'@function' => '_fedora_repository_render_image()', |
||||
'@preset' => 'fedora_repository_collection_thumbnail', |
||||
'@xsl' => 'sparql_to_html.xsl', |
||||
)), |
||||
); |
||||
|
||||
$form['advanced']['fedora_control_group_control_during_ingest'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t('Allow control groups select in datastream ingest'), |
||||
'#description' => t('Whether or not we should allow the user to select which control group to ingest a stream as, or to follow the old paradigm--to add stream IDed as XML as inline, and everything else as managed.'), |
||||
'#default_value' => variable_get('fedora_control_group_control_during_ingest', FALSE), |
||||
); |
||||
|
||||
//FITS functionality |
||||
$form['advanced']['enable_fits'] = array( |
||||
'#type' => 'checkbox', |
||||
'#title' => t('Enable FITS support?'), |
||||
'#description' => t('Whether or not we should create a FITS datastream upon object ingest.'), |
||||
'#default_value' => variable_get('enable_fits', FALSE), |
||||
); |
||||
|
||||
//FITS Path |
||||
$form['advanced']['fits_path'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Path to FITS executable'), |
||||
'#description' => t("Path to FITS program on your server. It must be accessible by Drupal (i.e. apache user)."), |
||||
'#default_value' => variable_get('fits_path','/usr/local/bin/fits.sh'), |
||||
); |
||||
|
||||
//Export functionality |
||||
$form['advanced']['module']['export_area'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Export area'), |
||||
'#default_value' => variable_get('export_area', file_directory_path() . '/fedora_export_area'), |
||||
'#description' => t("Path to the export area. It must be accessible by drupal (i.e. apache user)."), |
||||
'#required' => TRUE, |
||||
); |
||||
|
||||
$form['#attributes'] = array('enctype' => "multipart/form-data"); |
||||
|
||||
|
||||
return system_settings_form($form); |
||||
} |
||||
|
||||
/** |
||||
* Update Metadata |
||||
* @param type $form_id |
||||
* @param type $form_values |
||||
* @param type $client |
||||
* @return type |
||||
*/ |
||||
function updateMetaData($form_id, $form_values, $client) { |
||||
// ====================================== |
||||
// = begin creation of foxml dom object = |
||||
// ====================================== |
||||
$dom = new DomDocument("1.0", "UTF-8"); |
||||
$dom->formatOutput = TRUE; |
||||
|
||||
///begin writing qdc |
||||
|
||||
$oai = $dom->createElement("oai_dc:dc"); |
||||
$oai->setAttribute('xmlns:oai_dc', "http://www.openarchives.org/OAI/2.0/oai_dc/"); |
||||
$oai->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/"); |
||||
$oai->setAttribute('xmlns:dcterms', "http://purl.org/dc/terms/"); |
||||
$oai->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); |
||||
|
||||
// DC elements |
||||
$previousElement = NULL; // Used in case we have to nest elements for qualified dublin core. |
||||
|
||||
$label = null; |
||||
foreach ($form_values as $key => $value) { |
||||
//echo ($key); |
||||
if ($key == 'dc:title-0') { |
||||
$label = $value; |
||||
} |
||||
$index = strrpos($key, '-'); |
||||
$key = substr($key, 0, $index); |
||||
$test = substr($key, 0, 2); |
||||
if ($test == 'dc' || $test == 'ap') { // Don't try to process other form values. |
||||
try { |
||||
if (!strcmp(substr($key, 0, 4), 'app_')) { |
||||
$key = substr($key, 4); |
||||
$previousElement->appendChild($dom->createElement($key, $value)); |
||||
} |
||||
else { |
||||
$previousElement = $dom->createElement($key, $value); |
||||
$oai->appendChild($previousElement); |
||||
} |
||||
} catch (exception $e) { |
||||
drupal_set_message(t($e->getMessage()), 'error'); |
||||
continue; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Save the title |
||||
if ( $label != null ) |
||||
{ |
||||
$object = new Fedora_Item($form_values['pid']); |
||||
$object->modify_object($label); |
||||
} |
||||
|
||||
$dom->appendChild($oai); |
||||
|
||||
if (!$client) { |
||||
return; |
||||
} |
||||
|
||||
$pid = $form_values['pid']; |
||||
$dsId = $form_values['dsid']; |
||||
$params = array( |
||||
"pid" => $pid, |
||||
"dsID" => $dsId, |
||||
"altIDs" => "", |
||||
"dsLabel" => "Qualified Dublin Core", |
||||
"MIMEType" => "text/xml", |
||||
"formatURI" => "URL", |
||||
"dsContent" => $dom->saveXML(), "checksumType" => "DISABLED", "checksum" => "none", |
||||
"logMessage" => "datastream_modified", "force" => "TRUE"); |
||||
try { |
||||
$object = $client->__soapCall('ModifyDatastreamByValue', array($params)); |
||||
} catch (exception $e) { |
||||
drupal_set_message(t("Error updating metadata") . " " . $e->getMessage(), 'error'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* queries the collection object for a childsecurity datastream and if found parses it |
||||
* to determine if this user is allowed to ingest in this collection |
||||
* we assume if they are able to modify objects in the collection they can ingest as well. |
||||
* @param type $collection_pid |
||||
* @return type |
||||
*/ |
||||
function can_ingest_here($collection_pid) { |
||||
module_load_include('inc', 'fedora_repository', 'SecurityClass'); |
||||
$securityClass = new SecurityClass(); |
||||
return $securityClass->canIngestHere($collection_pid); |
||||
} |
||||
|
||||
/** |
||||
* Drupal's permissions at this point no xacml yet. xacml decisions are made by fedora |
||||
* @param type $collection_pid |
||||
* @return type |
||||
*/ |
||||
function canShowIngestForm($collection_pid) { |
||||
if (!fedora_repository_check_perm('ingest new fedora objects', $collection_pid)) { |
||||
$ingest_override_array = module_invoke_all('fedora_repository_can_ingest', $collection_pid); |
||||
$overrides = array_filter($ingest_override_array); |
||||
if (empty($overrides)) { |
||||
drupal_set_message(t('You do not have permission to ingest.'), 'error'); |
||||
return FALSE; |
||||
} |
||||
} |
||||
module_load_include('inc', 'fedora_repository', 'SecurityClass'); |
||||
$security_class = new SecurityClass(); |
||||
if (!$security_class->canIngestHere($collection_pid)) { |
||||
// Queries the collection object for a child security datastream and if found parses it |
||||
// to determine if this user is allowed to ingest in this collection |
||||
// we assume if they are able to modify objects in the collection they can ingest as well. |
||||
drupal_set_message(t('You do not have premission to ingest here.')); |
||||
return FALSE; |
||||
} |
||||
if ($collection_pid == NULL) { |
||||
drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error'); |
||||
return FALSE; |
||||
} |
||||
return TRUE; |
||||
} |
||||
|
||||
/** |
||||
* Creates the first page of the ingest form for editing QDC. |
||||
* |
||||
* @param string $collection_pid |
||||
* @param string $collection_label |
||||
* @param array $form_state |
||||
* |
||||
* @return array |
||||
*/ |
||||
function createQDCIngestFormPageOne($collection_pid, $collection_label, array &$form_state) { |
||||
if (($collection_policy = CollectionPolicy::loadFromCollection($collection_pid)) === FALSE) { |
||||
drupal_set_message(t('Unable to load collection policy \'' . $collection_pid . '\'.')); |
||||
return FALSE; |
||||
} |
||||
if (!($content_models = $collection_policy->getContentModels())) { |
||||
drupal_set_message(t('No content models associated with this collection: !collection_label. Please contact your administrator.', array('!collection_label' => $collection_label)), 'error'); |
||||
return FALSE; |
||||
} |
||||
$potential_models = array(); |
||||
foreach ($content_models as $content_model) { |
||||
$identifier = $content_model->getIdentifier(); |
||||
$name = $content_model->name; |
||||
$potential_models["$identifier"] = "$name"; |
||||
} |
||||
$identifier = key($potential_models); |
||||
$selected_model = isset($form_state['values']['models']) ? $form_state['values']['models'] : $identifier; |
||||
return array( |
||||
'indicator' => array( |
||||
'#type' => 'fieldset', |
||||
'#title' => t('Ingest digital object into collection_pid !collection_label Step #1', array('collection_pid' => $collection_pid, '!collection_label' => $collection_label)), |
||||
'models' => array( |
||||
'#type' => 'select', |
||||
'#title' => t('Content models available'), |
||||
'#options' => $potential_models, |
||||
'#default_value' => $selected_model, |
||||
'#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a>'), |
||||
), |
||||
), |
||||
'collection_pid' => array( |
||||
'#type' => 'hidden', |
||||
'#value' => $collection_pid |
||||
), |
||||
'submit' => array( |
||||
'#type' => 'submit', |
||||
'#submit' => array('fedora_repository_ingest_form_submit'), |
||||
'#value' => t('Next') |
||||
), |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Create the second page of the ingest form for editing QDC |
||||
* |
||||
* @param string $collection_pid |
||||
* @param string $collection_label |
||||
* @param array $form_state |
||||
* |
||||
* @return array |
||||
*/ |
||||
function createQDCIngestFormPageTwo($collection_pid, $collection_label, array &$form_state) { |
||||
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
||||
$form = array(); |
||||
$content_model_pid = ContentModel::getPidFromIdentifier($form_state['values']['models']); |
||||
$content_model_dsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); |
||||
if (($content_model = ContentModel::loadFromModel($content_model_pid, $content_model_dsid)) !== FALSE) { |
||||
$form = $content_model->buildIngestForm($form, $form_state); |
||||
if ($form === FALSE) { |
||||
drupal_set_message(t("Error Building Ingest Form."), 'error'); |
||||
foreach (ContentModel::$errors as $error) { |
||||
drupal_set_message($error, 'error'); |
||||
} |
||||
} |
||||
$form['collection_pid'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => $collection_pid |
||||
); |
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#submit' => array('fedora_repository_ingest_form_submit'), |
||||
'#value' => t('Ingest') |
||||
); |
||||
} |
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Create the QDC Ingest Form. |
||||
* |
||||
* @param type $collection_pid |
||||
* @param type $collection_label |
||||
* @param array $form_state |
||||
* |
||||
* @return array |
||||
*/ |
||||
function createQDCIngestForm($collection_pid, $collection_label, array &$form_state) { |
||||
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); |
||||
$form_state['storage']['step'] = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step']; |
||||
if ($form_state['storage']['step'] == 1) { |
||||
return $this->createQDCIngestFormPageOne($collection_pid, $collection_label, $form_state); |
||||
} |
||||
else { |
||||
return $this->createQDCIngestFormPageTwo($collection_pid, $collection_label, $form_state); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Create a multi step form (wizard) for ingesting objects into Fedora |
||||
* |
||||
* @param string $collection_pid |
||||
* @param string $collection_label |
||||
* @param array $form_state |
||||
* |
||||
* @return array |
||||
*/ |
||||
function createIngestForm($collection_pid, $collection_label, array &$form_state) { |
||||
if (!$this->canShowIngestForm($collection_pid)) { |
||||
return FALSE; |
||||
} |
||||
|
||||
drupal_set_title($collection_label); |
||||
if (module_exists('islandora_content_model_forms')) { |
||||
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); |
||||
try { |
||||
$form = new IngestObjectMetadataForm(); |
||||
return $form->create($collection_pid, $collection_label, $form_state); |
||||
} catch (Exception $e) { |
||||
//dd('An error occured; reverting to QDC form...'); |
||||
$form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form. |
||||
} |
||||
} |
||||
return $this->createQDCIngestForm($collection_pid, $collection_label, $form_state); |
||||
} |
||||
|
||||
/** |
||||
* this function may not be being used |
||||
* @param type $pid |
||||
* @param type $form_state |
||||
* @return string |
||||
*/ |
||||
function createAddDataStreamForm($pid, &$form_state) { |
||||
//dump_vars($form_state); |
||||
// Populate the list of datastream IDs. |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); |
||||
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
|
||||
$obj_helper = new ObjectHelper(); |
||||
$content_models = $obj_helper->get_content_models_list($pid); |
||||
$available_dsids = array(); |
||||
if (!empty($content_models)) { |
||||
foreach ($content_models as $content_model) { |
||||
|
||||
|
||||
$newElements = $content_model->listDatastreams(); |
||||
if (!empty($newElements)) { |
||||
$available_dsids = array_merge($available_dsids, $newElements); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$item = new Fedora_Item($pid); |
||||
$used_datastreams = $item->get_datastreams_list_as_SimpleXML(); |
||||
$used_datastream_ids = array(); |
||||
foreach ($used_datastreams->datastreamDef as $used_datastream) { |
||||
array_push($used_datastream_ids, $used_datastream->ID); |
||||
} |
||||
$unused_dsids = array(); |
||||
|
||||
if ($form_state['submitted'] && $form_state['clicked_button']['#value'] != 'OK') { |
||||
$form['add_datastream_label'] = array( |
||||
'#value' => t('<br /><h3>The datastream has been uploaded.</h3>'), |
||||
'#weight' => -10, |
||||
); |
||||
$form['#redirect'] = "fedora/repository/$pid/"; |
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t('OK') |
||||
); |
||||
return $form; |
||||
} |
||||
if (!empty($available_dsids)) { |
||||
$unused_dsids = array_diff($available_dsids, $used_datastream_ids); |
||||
if (empty($unused_dsids)) { |
||||
return; |
||||
} |
||||
} |
||||
|
||||
$form['fieldset'] = array( |
||||
'#type' => 'fieldset', |
||||
'#title' => t('Add datastream'), |
||||
); |
||||
//$form['add_datastream_label'] = array( |
||||
// '#value' => t('<br /><h3>Add Datastream:</h3>'), |
||||
// '#weight' => -10, |
||||
//); |
||||
|
||||
$form['fieldset']['pid'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => "$pid" |
||||
); |
||||
|
||||
$form['fieldset']['stream_label'] = array( |
||||
'#title' => 'Datastream Label', |
||||
'#required' => 'TRUE', |
||||
'#description' => t('A Human readable label'), |
||||
'#type' => 'textfield' |
||||
); |
||||
|
||||
$form['#attributes']['enctype'] = 'multipart/form-data'; |
||||
$form['fieldset']['add-stream-file-location'] = array( |
||||
'#type' => 'file', |
||||
'#title' => t('Upload Document'), |
||||
'#size' => 48, |
||||
// '#required'=>'TRUE', |
||||
'#description' => t('The file to upload. (Only for Managed and Inline)') |
||||
); |
||||
|
||||
if (variable_get('fedora_control_group_control_during_ingest', FALSE)) { |
||||
$form['fieldset']['ds_reference'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Datastream reference'), |
||||
'#size' => 48, |
||||
'#description' => t('A URL reference to resolve for the contents of the datastream. (Required for External and Redirect, but will still work for Managed and Inline.)'), |
||||
); |
||||
} |
||||
|
||||
$form['#redirect'] = "fedora/repository/$pid/"; |
||||
$form['fieldset']['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t('Add Datastream') |
||||
); |
||||
|
||||
if (!empty($unused_dsids)) { |
||||
$form['fieldset']['stream_id'] = array( |
||||
'#type' => 'select', |
||||
'#title' => t('Datastream ID'), |
||||
'#default_value' => variable_get('feed_item_length', 'teaser'), |
||||
'#weight' => -1, |
||||
'#description' => t('Datastream IDs defined by the content model.'), |
||||
'#options' => array_combine($unused_dsids, $unused_dsids), |
||||
); |
||||
} |
||||
else { |
||||
$form['fieldset']['stream_id'] = array( |
||||
'#title' => 'Datastream ID', |
||||
'#required' => 'TRUE', |
||||
'#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores.'), |
||||
'#type' => 'textfield', |
||||
'#weight' => -1, |
||||
); |
||||
} |
||||
|
||||
if (variable_get('fedora_control_group_control_during_ingest', FALSE)) { |
||||
$form['fieldset']['control_group'] = array( |
||||
'#type' => 'select', |
||||
'#title' => t('Control group'), |
||||
'#options' => array( |
||||
'X' => t('Inline XML'), |
||||
'M' => t('Managed datastream'), |
||||
'E' => t('Externally Referenced/managed datastream'), |
||||
'R' => t('Redirect datastream'), |
||||
), |
||||
'#description' => t('The manner in which the datastream will be stored. "Inline XML" must be XML and will be placed directly into the FOXML for the object. "Managed" datastreams are made to live on the filesystem as discrete files in the Fedora data directory. Both "Redirect" and "External" streams are URL references; the difference being the redirect stream instruct clients to perform an HTTP redirect, such that the data does not pass though Fedora (useful for streaming). External streams are mediated (by which I mean loaded and streamed from) the Fedora server.'), |
||||
'#weight' => 0, |
||||
); |
||||
} |
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Create QDC Edit form. |
||||
* |
||||
* @param string $pid |
||||
* @param string $dsid |
||||
* @param object $client |
||||
* @param array $form_state |
||||
* |
||||
* @return string |
||||
*/ |
||||
function createQDCEditForm($pid, $dsid, $client, &$form_state) { |
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$dsid = empty($dsid) ? 'QDC' : $dsid; |
||||
|
||||
$item = new fedora_item($pid); |
||||
$content = trim($item->get_datastream_dissemination($dsid)); |
||||
|
||||
$doc = new DOMDocument(); |
||||
if (!$doc->loadXML($content)) { |
||||
echo "error loading xml"; |
||||
} |
||||
$oai_dc = $doc->getElementsByTagName('dc'); |
||||
$dcItems = $oai_dc->item(0)->getElementsByTagName('*'); |
||||
$form = array(); |
||||
for ($i = 0; $i < $dcItems->length; $i++) { |
||||
$name = $dcItems->item($i)->nodeName; |
||||
if ($name == 'dc:description') { |
||||
$form["$name" . '-' . "$i"] = array( |
||||
'#title' => $name, |
||||
'#type' => 'textarea', |
||||
'#default_value' => $dcItems->item($i)->nodeValue, |
||||
'#description' => 'Dublin Core ' . substr($dcItems->item($i)->nodeName, 3) |
||||
); |
||||
} |
||||
elseif ($name == 'dc:title') { |
||||
$form["$name" . '-' . "$i"] = array( |
||||
'#title' => $name, |
||||
'#type' => 'textfield', |
||||
'#required' => 'TRUE', |
||||
'#default_value' => $dcItems->item($i)->nodeValue, |
||||
'#description' => 'Dublin Core ' . substr($dcItems->item($i)->nodeName, 3) |
||||
); |
||||
} |
||||
else { |
||||
if ($oai_dc->item(0)->nodeName != $dcItems->item($i)->parentNode->nodeName) { |
||||
$description = strstr($name, ':'); |
||||
$form['app_' . "$name" . '-' . "$i"] = array( |
||||
'#title' => $name, |
||||
'#type' => 'textfield', |
||||
'#default_value' => $dcItems->item($i)->nodeValue, |
||||
'#description' => 'Dublin Core ' . substr($description, 1) |
||||
); |
||||
} |
||||
else { |
||||
$field_type = 'textfield'; |
||||
$value = $dcItems->item($i)->nodeValue; |
||||
if ($name == 'dc:coverage') { |
||||
$value = ''; |
||||
} |
||||
if ($name == 'dc:rights') { |
||||
$field_type = 'textarea'; |
||||
} |
||||
$description = strstr($name, ':'); |
||||
$form["$name" . '-' . "$i"] = array( |
||||
'#title' => $name, |
||||
'#type' => $field_type, |
||||
'#default_value' => $value, |
||||
'#description' => 'Dublin Core ' . substr($description, 1) |
||||
); |
||||
} |
||||
} |
||||
} |
||||
$form['pid'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => "$pid" |
||||
); |
||||
$form['dsid'] = array( |
||||
'#type' => 'hidden', |
||||
'#value' => "$dsid" |
||||
); |
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t('Update Metadata'), |
||||
); |
||||
return $form; |
||||
} |
||||
|
||||
/** |
||||
* Creates a drupal form to edit either the QDC or DC datastream |
||||
* @param type $pid |
||||
* @param type $dsid |
||||
* @param type $client |
||||
* @param boolean $form_state |
||||
* @return type |
||||
*/ |
||||
function createMetaDataForm($pid, $dsid, $client, &$form_state) { |
||||
if (module_exists('islandora_content_model_forms')) { |
||||
module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); |
||||
try { |
||||
$form = new EditObjectMetadataForm($form_state); |
||||
return $form->create($pid, $client, $form_state); |
||||
} catch (Exception $e) { |
||||
$form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form. |
||||
} |
||||
} |
||||
return $this->createQDCEditForm($pid, $dsid, $client, $form_state); |
||||
} |
||||
|
||||
/** |
||||
* Creates a form for replacing datastream |
||||
* @param type $pid |
||||
* @param type $dsId |
||||
* @param type $dsLabel |
||||
* @param type $form_state |
||||
* @return type |
||||
*/ |
||||
function createReplaceDataStreamForm($pid, $dsId, $dsLabel, &$form_state) { |
||||
$form = array(); |
||||
|
||||
$form['#attributes']['enctype'] = 'multipart/form-data'; |
||||
|
||||
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
||||
$item = new Fedora_Item($pid); |
||||
$info = $item->get_datastream_info($dsId); |
||||
$control_group = $info->datastream->controlGroup; |
||||
if (in_array($control_group, array('M', 'X'))) { |
||||
$form['file'] = array( |
||||
'#type' => 'file', |
||||
'#title' => t('Upload Document'), |
||||
'#description' => t('A file with which to replace the contents of this datastream.'), |
||||
); |
||||
} |
||||
if ($control_group != 'X') { |
||||
$form['reference'] = array( |
||||
'#type' => 'textfield', |
||||
'#title' => t('Reference to object'), |
||||
'#description' => t('A URL the datastream will be updated to reference.'), |
||||
); |
||||
} |
||||
if ($control_group == 'M') { |
||||
$form['note'] = array( |
||||
'#type' => 'item', |
||||
'#title' => t('NOTE'), |
||||
'#value' => t('If both a file and a reference are given, the file will be given preference.'), |
||||
); |
||||
} |
||||
|
||||
$form['pid'] = array( |
||||
'#type' => 'value', |
||||
'#value' => $pid, |
||||
); |
||||
|
||||
$form['dsId'] = array( |
||||
'#type' => 'value', |
||||
'#value' => $dsId, |
||||
); |
||||
|
||||
$form['dsLabel'] = array( |
||||
'#type' => 'value', |
||||
'#value' => $dsLabel, |
||||
); |
||||
|
||||
$form['submit'] = array( |
||||
'#type' => 'submit', |
||||
'#value' => t('Replace Datastream') |
||||
); |
||||
|
||||
return $form; |
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 364 B |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 760 B |