Author: sevein Date: Fri Oct 7 16:11:51 2011 New Revision: 9977 Log: Initial commit of qtSwordPlugin
Added: trunk/plugins/qtSwordPlugin/ trunk/plugins/qtSwordPlugin/config/ trunk/plugins/qtSwordPlugin/config/qtSwordPluginConfiguration.class.php trunk/plugins/qtSwordPlugin/modules/ trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/ trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/ trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/ trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php Added: trunk/plugins/qtSwordPlugin/config/qtSwordPluginConfiguration.class.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/plugins/qtSwordPlugin/config/qtSwordPluginConfiguration.class.php Fri Oct 7 16:11:51 2011 (r9977) @@ -0,0 +1,32 @@ +<?php + +/* + * This file is part of Qubit Toolkit. + * + * Qubit Toolkit 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. + * + * Qubit Toolkit 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 Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>. + */ + +class qtSwordPluginConfiguration extends sfPluginConfiguration +{ + public static + $summary = 'SWORD plugin.', + $version = '1.0.0'; + + public function initialize() + { + $enabledModules = sfConfig::get('sf_enabled_modules'); + $enabledModules[] = 'qtSwordPlugin'; + sfConfig::set('sf_enabled_modules', $enabledModules); + } +} Added: trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php Fri Oct 7 16:11:51 2011 (r9977) @@ -0,0 +1,77 @@ +<?php + +/* + * This file is part of Qubit Toolkit. + * + * Qubit Toolkit 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. + * + * Qubit Toolkit 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 Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>. + */ + +class qtSwordPluginServicedocumentAction extends sfAction +{ + public function execute($request) + { + $this->version = '1.3'; + $this->verbose = 'false'; + $this->noOp = 'false'; + $this->maxUploadSize = QubitDigitalObject::getMaxUploadSize() / 1024; // From bytes to kilobytes + + // Logging for dev purposes + /* + $this->logger = sfContext::getInstance()->getLogger(); + $this->logger->debug("START"); + $this->renderArray($_POST); + $this->renderArray($_GET); + $this->renderArray(getallheaders()); + */ + + /* + 'Content-MD5' + 'X-On-Behalf-Of' + 'X-Packaging' + 'Content-Type' + 'Content-Length' + 'X-No-Op' + 'X-Verbose' + 'Content-Disposition: filename=' + */ + + if (isset($request->getAttribute('sf_route')->resource)) + { + $this->resource = $this->getRoute()->resource; + + $this->title = $this->resource->__toString(); + + $this->workspaces = $this->resource->getChildren(); + } + else + { + $this->title = sfConfig::get('app_siteTitle'); + + $criteria = new Criteria; + $criteria->add(QubitInformationObject::PARENT_ID, QubitInformationObject::ROOT_ID, Criteria::IN); + + $this->workspaces = QubitInformationObject::get($criteria); + } + + $request->setRequestFormat('xml'); + } + + public function renderArray($item) + { + foreach ($item as $key => $value) + { + $this->logger->debug($key . ": " . $value); + } + } +} Added: trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php Fri Oct 7 16:11:51 2011 (r9977) @@ -0,0 +1,52 @@ +<?php echo '<?xml version="1.0" encoding="'.sfConfig::get('sf_charset', 'UTF-8').'" ?>' ?> +<service xmlns="http://www.w3.org/2007/app" + xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:sword="http://purl.org/net/sword/" + xmlns:dcterms="http://purl.org/dc/terms/"> + + <sword:version><?php echo $version ?></sword:version> + <sword:verbose><?php echo $verbose ?></sword:verbose> + <sword:noOp><?php echo $noOp ?></sword:noOp> + <sword:maxUploadSize><?php echo $maxUploadSize ?></sword:maxUploadSize> + + <workspace> + <atom:title type="text"><?php echo $title ?></atom:title> + + <?php foreach ($workspaces as $item): ?> + + <collection href="<?php echo url_for(array($item, 'module' => 'qtSwordPlugin', 'action' => 'deposit'), true) ?>"> + + <atom:title type="text"><?php echo render_title($item) ?></atom:title> + + <!-- Accepted media ranges --> + <accept>application/zip</accept> + <accept>application/xml</accept> + + <!-- MAY be included. Used for a human-readable description of collection policy. Include either a text description or a URI. --> + <sword:collectionPolicy>No guarantee of service, or that deposits will be retained for any length of time.</sword:collectionPolicy> + + <!-- SHOULD be included. Used to indicate if mediated deposit is allowed on the defined collection. --> + <sword:mediation>true</sword:mediation> + + <!-- MAY be included. Used for a human-readable statement about what treatment the deposited resource will receive. --> + <sword:treatment>This is a server</sword:treatment> + + <!-- MAY be included. Used to identify the content packaging types supported by this collection. SHOULD be a URI from [SWORD-TYPES]. The q attribute MAY be used to indicate relative preferences between packaging formats (See Part A Section 1.1). --> + <sword:acceptPackaging q="1.0">http://purl.org/net/sword-types/METSDSpaceSIP</sword:acceptPackaging> + <sword:acceptPackaging q="0.5">http://purl.org/net/sword-types/bagit</sword:acceptPackaging> + + <!-- 0 or more MAY be included to direct clients to nested service definitions. If present, the value MUST be a URI that dereferences to another SWORD Service Document. --> + <?php if (0 < count($item->getChildren())): ?> + <sword:service><?php echo url_for(array($item, 'module' => 'qtSwordPlugin', 'action' => 'servicedocument'), true) ?></sword:service> + <?php endif; ?> + + <!-- The use of a Dublin Core dcterms:abstract element containing a description of the Collection is RECOMMENDED. --> + <dcterms:abstract>Collection description</dcterms:abstract> + + </collection> + + <?php endforeach; ?> + + </workspace> + +</service> -- You received this message because you are subscribed to the Google Groups "Qubit Toolkit Commits" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/qubit-commits?hl=en.
